{"id":19716637,"url":"https://github.com/ilammy/fluid-let","last_synced_at":"2025-04-29T20:30:45.778Z","repository":{"id":57630932,"uuid":"174893600","full_name":"ilammy/fluid-let","owner":"ilammy","description":"Dynamically scoped variables in Rust","archived":false,"fork":false,"pushed_at":"2021-10-12T13:07:43.000Z","size":59,"stargazers_count":11,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-27T18:41:33.401Z","etag":null,"topics":["dynamic-variable","library","lisp","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilammy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-03-10T23:27:18.000Z","updated_at":"2025-04-08T19:47:37.000Z","dependencies_parsed_at":"2022-09-26T20:11:37.174Z","dependency_job_id":null,"html_url":"https://github.com/ilammy/fluid-let","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilammy%2Ffluid-let","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilammy%2Ffluid-let/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilammy%2Ffluid-let/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilammy%2Ffluid-let/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilammy","download_url":"https://codeload.github.com/ilammy/fluid-let/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251578283,"owners_count":21612009,"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","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":["dynamic-variable","library","lisp","rust"],"created_at":"2024-11-11T22:42:51.828Z","updated_at":"2025-04-29T20:30:45.481Z","avatar_url":"https://github.com/ilammy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"fluid-let\n=========\n\n[![Build Status](https://github.com/ilammy/fluid-let/workflows/Tests/badge.svg)](https://github.com/ilammy/fluid-let/actions)\n[![Rust Documentation](https://docs.rs/fluid-let/badge.svg)](https://docs.rs/fluid-let)\n[![Latest Version](https://img.shields.io/crates/v/fluid-let.svg)](https://crates.io/crates/fluid-let)\n\n[**fluid-let**](https://crates.io/crates/fluid-let) implements _dynamically scoped_ variables.\n\nDynamic or _fluid_ variables are a handy way to define global configuration values.\nThey come from the Lisp family of languages where they are relatively popular for this use case.\n\n## Usage\n\nAdd this to your Cargo.toml:\n\n```toml\n[dependencies]\nfluid-let = \"1\"\n```\n\nYou can declare global dynamic variables using `fluid_let!` macro.\nSuppose you want to have a configurable `Debug` implementation for your hashes,\ncontrolling whether to print out the whole hash or a truncated version:\n\n```rust\nuse fluid_let::fluid_let;\n\nfluid_let!(pub static DEBUG_FULL_HASH: bool);\n```\n\nEnable full print out using the `fluid_set!` macro.\nAssignments to dynamic variables are effective for a certain _dynamic_ scope.\nIn this case, while the function is being executed:\n\n```rust\nuse fluid_let::fluid_set;\n\nfn some_important_function() {\n    fluid_set!(DEBUG_FULL_HASH, \u0026true);\n\n    // Hashes will be printed out with full precision in this function\n    // as well as in all functions that it calls.\n}\n```\n\nAnd here is how you can implement `Debug` that uses dynamic configuration:\n\n```rust\nimpl fmt::Debug for Hash {\n    fn fmt(\u0026self, f: \u0026mut fmt::Formatter) -\u003e fmt::Result {\n        let full = DEBUG_FULL_HASH.copied().unwrap_or(false);\n\n        write!(f, \"Hash(\")?;\n        if full {\n            for byte in \u0026self.value {\n                write!(f, \"{:02X}\", byte)?;\n            }\n        } else {\n            for byte in \u0026self.value[..4] {\n                write!(f, \"{:02X}\", byte)?;\n            }\n            write!(f, \"...\")?;\n        }\n        write!(f, \")\")\n    }\n}\n```\n\nHere we print either the full value of the hash, or a truncated version,\nbased on whether debugging mode has been enabled by the caller or not.\n\n## License\n\nThe code is licensed under **MIT license** (see [LICENSE](LICENSE)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filammy%2Ffluid-let","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filammy%2Ffluid-let","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filammy%2Ffluid-let/lists"}