GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs.rs
  • lazy_static-0.2.11
  • i686-apple-darwin
  • i686-pc-windows-msvc
  • i686-unknown-linux-gnu
  • x86_64-apple-darwin
  • x86_64-pc-windows-msvc
  • x86_64-unknown-linux-gnu
  • Feature flags
  • About docs.rs
  • Badges
  • Builds
  • Metadata
  • Shorthand URLs

This view

  • Original page
  • New address

GeezerVison is showing docs.rs — lazy_static 0.2.11 - Docs.rs

lazy_static 0.2.11

A macro for declaring lazily evaluated statics in Rust.
  • Crate
  • Source
  • Builds
  • Feature flags
Documentation
  • Ø build duration
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rust-lang-nursery/lazy-static.rs
    2033 125 35
  • crates.io
  • Dependencies
    • compiletest_rs ^0.3 normal
    • spin ^0.4.6 normal
  • Versions
    • 1.5.1 (2026-10-01)
    • 1.5.0 (2024-06-21)
    • 1.4.0 (2019-08-26)
    • 1.3.0 (2019-02-27)
    • 1.2.0 (2018-11-04)
    • 1.1.1 (2020-01-13)
    • 1.1.0 (2018-08-05)
    • 1.0.2 (2018-07-15)
    • 1.0.1 (2018-05-29)
    • 1.0.0 (2017-11-29)
    • 0.2.11 (2017-11-20)
    • 0.2.10 (2017-11-13)
    • 0.2.9 (2017-09-28)
    • 0.2.8 (2017-04-12)
    • 0.2.7 (2017-04-12)
    • 0.2.6 (2017-04-01)
    • 0.2.5 (2017-03-25)
    • 0.2.4 (2017-03-04)
    • 0.2.3 (2017-03-04)
    • 0.2.2 (2016-11-11)
    • 0.2.1 (2016-04-27)
    • 0.2.0 (2016-04-13)
    • 0.1.16 (2016-04-11)
    • 0.1.15 (2015-10-02)
    • 0.1.14 (2015-08-03)
    • 0.1.13 (2015-08-03)
    • 0.1.12 (2015-07-21)
    • 0.1.11 (2015-05-30)
    • 0.1.10 (2015-04-06)
    • 0.1.9 (2015-04-06)
    • 0.1.8 (2015-03-07)
    • 0.1.7 (2015-01-16)
    • 0.1.6 (2015-01-10)
    • 0.1.5 (2015-01-08)
    • 0.1.4 (2015-01-03)
    • 0.1.3 (2014-12-26)
    • 0.1.2 (2014-12-21)
    • 0.1.1 (2014-11-23)
    • 0.1.0 (2014-11-23)
  • Owners
  • rust-lang-owner

lazy-static.rs

A macro for declaring lazily evaluated statics in Rust.

Using this macro, it is possible to have statics that require code to be executed at runtime in order to be initialized. This includes anything requiring heap allocations, like vectors or hash maps, as well as anything that requires non-const function calls to be computed.

Travis-CI Status

Getting Started

lazy-static.rs is available on crates.io. It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.

At the point of the last update of this README, the latest published version could be used like this:

Add the following dependency to your Cargo manifest...

[dependencies]
lazy_static = "0.2"

...and see the docs for how to use it.

Example

#[macro_use]
extern crate lazy_static;

use std::collections::HashMap;

lazy_static! {
    static ref HASHMAP: HashMap<u32, &'static str> = {
        let mut m = HashMap::new();
        m.insert(0, "foo");
        m.insert(1, "bar");
        m.insert(2, "baz");
        m
    };
}

fn main() {
    // First access to `HASHMAP` initializes it
    println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());

    // Any further access to `HASHMAP` just returns the computed value
    println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap());
}

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.