Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
patches/ | 03-May-2024 | - | 69 | 63 | ||
src/ | 03-May-2024 | - | 307 | 129 | ||
tests/ | 03-May-2024 | - | 186 | 142 | ||
.cargo_vcs_info.json | D | 03-May-2024 | 74 | 6 | 5 | |
.gitignore | D | 03-May-2024 | 29 | 5 | 4 | |
Android.bp | D | 03-May-2024 | 2.9 KiB | 105 | 95 | |
Cargo.toml | D | 03-May-2024 | 1.5 KiB | 47 | 40 | |
Cargo.toml.orig | D | 03-May-2024 | 1 KiB | 35 | 26 | |
LICENSE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-APACHE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | D | 03-May-2024 | 1 KiB | 26 | 22 | |
METADATA | D | 03-May-2024 | 407 | 20 | 19 | |
MODULE_LICENSE_APACHE2 | D | 03-May-2024 | 0 | |||
OWNERS | D | 03-May-2024 | 40 | 2 | 1 | |
README.md | D | 03-May-2024 | 2.6 KiB | 80 | 54 | |
TEST_MAPPING | D | 03-May-2024 | 464 | 24 | 23 | |
cargo2android.json | D | 03-May-2024 | 226 | 12 | 12 |
README.md
1lazy-static.rs 2============== 3 4A macro for declaring lazily evaluated statics in Rust. 5 6Using this macro, it is possible to have `static`s that require code to be 7executed at runtime in order to be initialized. 8This includes anything requiring heap allocations, like vectors or hash maps, 9as well as anything that requires non-const function calls to be computed. 10 11[](https://travis-ci.com/rust-lang-nursery/lazy-static.rs) 12[](https://crates.io/crates/lazy_static) 13[](https://docs.rs/lazy_static) 14[](https://github.com/rust-lang-nursery/lazy-static.rs#license) 15 16## Minimum supported `rustc` 17 18`1.27.2+` 19 20This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes. 21 22 23# Getting Started 24 25[lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static). 26It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. 27 28At the point of the last update of this README, the latest published version could be used like this: 29 30Add the following dependency to your Cargo manifest... 31 32```toml 33[dependencies] 34lazy_static = "1.4.0" 35``` 36 37...and see the [docs](https://docs.rs/lazy_static) for how to use it. 38 39# Example 40 41```rust 42#[macro_use] 43extern crate lazy_static; 44 45use std::collections::HashMap; 46 47lazy_static! { 48 static ref HASHMAP: HashMap<u32, &'static str> = { 49 let mut m = HashMap::new(); 50 m.insert(0, "foo"); 51 m.insert(1, "bar"); 52 m.insert(2, "baz"); 53 m 54 }; 55} 56 57fn main() { 58 // First access to `HASHMAP` initializes it 59 println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); 60 61 // Any further access to `HASHMAP` just returns the computed value 62 println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap()); 63} 64``` 65 66## License 67 68Licensed under either of 69 70 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 71 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 72 73at your option. 74 75### Contribution 76 77Unless you explicitly state otherwise, any contribution intentionally submitted 78for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any 79additional terms or conditions. 80