{"id":18535796,"url":"https://github.com/daniel5151/analog_literals","last_synced_at":"2025-09-12T03:13:50.160Z","repository":{"id":57487835,"uuid":"370190879","full_name":"daniel5151/analog_literals","owner":"daniel5151","description":"Multi-Dimensional Analog Literals in Rust","archived":false,"fork":false,"pushed_at":"2021-05-24T01:16:29.000Z","size":8,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-02T01:39:29.042Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daniel5151.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-24T01:03:43.000Z","updated_at":"2024-04-12T03:26:27.000Z","dependencies_parsed_at":"2022-08-29T11:21:41.069Z","dependency_job_id":null,"html_url":"https://github.com/daniel5151/analog_literals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daniel5151/analog_literals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel5151%2Fanalog_literals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel5151%2Fanalog_literals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel5151%2Fanalog_literals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel5151%2Fanalog_literals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daniel5151","download_url":"https://codeload.github.com/daniel5151/analog_literals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel5151%2Fanalog_literals/sbom","scorecard":{"id":319295,"data":{"date":"2025-08-11","repo":{"name":"github.com/daniel5151/analog_literals","commit":"9a28b6f7b87d1872c7f3f38829d2536a78e07b3a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Do What The F*ck You Want To Public License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T00:59:01.436Z","repository_id":57487835,"created_at":"2025-08-18T00:59:01.437Z","updated_at":"2025-08-18T00:59:01.437Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274747697,"owners_count":25341936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T19:27:42.687Z","updated_at":"2025-09-12T03:13:50.134Z","avatar_url":"https://github.com/daniel5151.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-Dimensional Analog Literals in Rust\n\n[![](http://meritbadge.herokuapp.com/analog_literals)](https://crates.io/crates/analog_literals)\n[![](https://docs.rs/analog_literals/badge.svg)](https://docs.rs/analog_literals)\n\n\nInspired by the ~~abhorrent~~ incredible\n[Multi-Dimensional Analog Literals](http://www.eelis.net/C++/analogliterals.xhtml)\nlibrary created by Eelis back in 2006, I am proud to present\n`analog_literal!` - a Rust macro that enables embedding analog literals\ndirectly into Rust code.\n\nJust take a look at this incredible set of features!\n\n- Support for every physical dimension from 0 to N (for all N \u003c= 3)!\n- Strict syntax checking - no mismatched widths, lengths, or heights!\n- Entirely safe Rust, enforced by `#[deny(unsafe_code)]`!\n- Entirely `const` evaluatable - use analog literals in any `const` context!\n- `#![no_std]` by default, _without_ relying on `alloc`!\n- Dependency Free!\n- Open source under a _very_ permissive license!\n- Made with love, passion, and a disregard of all things holy!\n\n# Modes of Operation\n\nThe single `analog_literal!` macro can be used to define 3 different kinds\nof analog literals: a 1D line, a 2D rectangle, and a 3D cuboid.\n\n## 1D Lines\n\nA 1D analog literal (known in professional circles as a \"line\") is perfect\nfor all those times when you wanted to self-document just how big (or\nsmall!) a scalar was.\n\nDefining them works exactly as you'd expect:\n\n```rust\nlet mine = analog_literal! { +--------------------+ };\nlet yours = analog_literal! { +----------+ };\nassert!(mine \u003e yours);\n```\n\n1D analog literals can also be defined using alternative `I` terminators,\nfor that classic 3rd grade math class feeling:\n\n```rust\nassert_eq!(\n      analog_literal! { I----I }\n    + analog_literal! { I------I },\n/*    ---------------------------------------------- */\n      analog_literal! { I----------I },\n);\n```\n\nHeck, you can even use them inline in `const` contexts to quickly and easy\nvisualize just how large of an array you're allocating!\n\n```rust\nlet buf = [0; analog_literal!{ +--------------------------------+ }];\n```\n\nEducational!\n\n## 2D Rectangles\n\nWhile there are plenty of Rust libraries out there trying to provide a\nelegant, cross-platform solution to writing GUIs, not a single one has a\ngood way of _visually_ representing the GUI that the code is trying to\nrepresent.\n\nWell, with a bit of help from 2D analog literals (sometimes referred to by\nseasoned mathematicians as \"rectangles\"), these libraries can be\n_turbocharged_ with true WYSIWYG capabilities!\n\n```rust\nconst MODAL_POPUP: Rectangle = analog_literal! {\n    +----------------------------------------------------------+\n    |                                                          |\n    |       /*----------------------------------------*/       |\n    |       /* Do you accept the terms and conditions */       |\n    |       /* and agree to sell your eternal soul to */       |\n    |       /*        the dark lord beelzebub?        */       |\n    |       /*----------------------------------------*/       |\n    |                                                          |\n    |   /* Yes */                             /* Also Yes */   |\n    |                                                          |\n    +----------------------------------------------------------+\n};\n\nassert_eq!(MODAL_POPUP.w, 29);\nassert_eq!(MODAL_POPUP.h, 9);\n\nassert_eq!(MODAL_POPUP.area(), 261);\n```\n\nThe possibilities are endless!\n\n## 3D Cuboids\n\nSay you're trying to solve the [packing problem](https://en.wikipedia.org/wiki/Bin_packing_problem)\nfor fitting the largest number of dogecoin mining rigs in your 1.5 bedroom\nSF \"apartment\". A 1x programmer would probably just use a couple of boring\n'ol cOnStAnTs to define the length, width, and height of their dogecoin\nminers. Of course, you're not a 1x programmer, you're a _10x programmer_, so\nyou use a 3D analog literal (colloquially referred to as a \"cuboid\") to\n_visually_ represent the dimensions of your mining rigs:\n\n```rust\nconst MINING_RIG: Cuboid = analog_literal! {\n                     +------------------------------------------+\n                    /                                          /|\n                   /                                          / +\n                  /                   /**/                   / /\n                 /                   /**/                   / /\n                /                   /**/                   / /\n               /                                          / /\n              /                                          / /\n             /                                          / /\n            /                                          / /\n           /                                          / /\n          /                                          / /\n         /                                          / /\n        /                                          / /\n       /                                          / /\n      /                                          / /\n     /                                          / /\n    +------------------------------------------+ /\n    | /* -= dogecoin-one =- */         /*(o)*/ |/\n    +------------------------------------------+\n};\n\nassert_eq!(MINING_RIG.w, 21);\nassert_eq!(MINING_RIG.h, 1);\nassert_eq!(MINING_RIG.l, 16);\n\nassert_eq!(MINING_RIG.volume(), 336);\n```\n\nOh yeah, I can taste those DOGE tendies already!\n\n# Putting it all together\n\nBrace yourself, because the following example may very well shake you to the core:\n\n```rust\nuse analog_literals::analog_literal as al;\n\nal! {\n       +----------+\n      /          /|\n     /          / |\n    /          /  +\n   /          /  /\n  +----------+  /\n  |          | /\n  |          |/\n  +----------+ }.volume() == al! { +----+\n                                   |    |\n                                   |    |\n                                   |    |\n                                   |    |\n                                   |    |\n                                   +----+ }.area() * al! { +--------+ }\n```\n\n![](https://media1.tenor.com/images/bcb961b67dc5ec34381372494c85c8fe/tenor.gif)\n\n# Safety and Syntax Validation\n\nIn true Rust fashion, this library strives to be as safe as can be. Not only\nis it 100% unsafe code free (enforced by `#![deny(unsafe_code)]` in the\ncrate root), but it will also catch any malformed analog literals at compile\ntime!\n\nI'm sure we've all been in this situation: it's 4:55 on a weekday, you're\ndesperate for another cup of coffee, and you really feel like just packing\nit in early. You decide to call it for the day, and leave yourself a comment\nto pick up where you left off tomorrow...\n\n```rust,compile_fail\nconst YET_ANOTHER_RECT: Rectangle = analog_literal! {\n    +----------------+\n    |                |\n    |                |\n    +------------+ // TODO: type more `--`...\n};\n```\n\nYou come back in the next morning, and without thinking, you decide to check\nin what you had from yesterday into prod. But it's okay, because as the CI\nruns on your shoddy code from the day before, the Rust compiler helpfully\nspits out a compilation error!\n\n```text\nerror[E0080]: evaluation of constant value failed\n  --\u003e src/lib.rs:364:37\n   |\n5  |   const YET_ANOTHER_RECT: Rectangle = analog_literal! {\n   |  _____________________________________^\n6  | |     +----------------+\n7  | |     |                |\n8  | |     |                |\n9  | |     +------------+ // TODO: type more `--`...\n10 | | };\n   | |_^ attempt to compute `0_usize - 1_usize`, which would overflow\n   |\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n```\n\nLook, I never said the error messages would be descriptive, okay...\n\nBut hey, would you look at that! With `analog_literal!`, you can rest easy\nknowing that _your_ literals are guaranteed to be well formed _From Top to\nBottom, and Left to Right™_\n\n---\n\nSo what are you waiting for! Go ahead and add `analog_literals` to your\nproject _today!_\n\n```toml\n[dependencies]\nanalog_literals = \"*\"\n```\n\n# Final Comments\n\nI'm not gonna lie - I was already half-way done implementing 3D literals\nbefore I'd even thought to check if anyone else had done something as stupid\nas this already. Lo and behold, [jswrenn/analit](https://github.com/jswrenn/analit)\nbeat me to the punch by a whopping 6 years!\n\nA smarter man might have stopped working on his shoddy rewrite and scrapped\nhis shoddy POC then and there. Instead, stubborn as I am, I decided to push\nforward and spent another handful of hours polishing it up, adding syntax\nvalidation, and writing a whole _mess_ of docs.\n\nDo I regret it? Ehh, maybe.\n\nIt is funny tho? I mean, I think so.\n\n---\n\nOh, and lastly: please, _please_ don't use this library in an actual\nproject.\n\nIf I saw something like this while perusing a crate's source code, I'd\nprobably nope the heck out of there, turn off my computer, and go on a long\nwalk to contemplate what kind of life choices could have led someone to\nthinking that including `analog_literals` in their project would be a good\nidea.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel5151%2Fanalog_literals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniel5151%2Fanalog_literals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel5151%2Fanalog_literals/lists"}