Created
October 5, 2018 06:21
-
-
Save rust-play/333964d735c4ac04da5a4e53daf501b9 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(warnings)] | |
#[macro_use] | |
extern crate lazy_static; // 1.1.0 | |
use lazy_static::LazyStatic; | |
struct MyFoo {} | |
impl MyFoo { | |
pub fn initialize(&self) { | |
println!("MyFoo instance is being initialized!"); | |
} | |
} | |
lazy_static! { | |
static ref MY_FOO: MyFoo = { | |
println!("MY_FOO is being initialized!"); | |
MyFoo{} | |
}; | |
} | |
fn main() { | |
// LazyStatic::initialize(&MY_FOO); | |
MY_FOO.initialize(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment