Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created October 5, 2018 06:21
Show Gist options
  • Save rust-play/333964d735c4ac04da5a4e53daf501b9 to your computer and use it in GitHub Desktop.
Save rust-play/333964d735c4ac04da5a4e53daf501b9 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![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