From 3c70fdf3b9f4994e6087e046328d4cb1f809c92b Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Thu, 30 Jan 2020 22:15:35 +0800 Subject: [PATCH] add lazy_static --- lazy_static/Cargo.toml | 10 ++++++++++ lazy_static/src/main.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 lazy_static/Cargo.toml create mode 100644 lazy_static/src/main.rs diff --git a/lazy_static/Cargo.toml b/lazy_static/Cargo.toml new file mode 100644 index 0000000..2b52baf --- /dev/null +++ b/lazy_static/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "lazy_static" +version = "0.1.0" +authors = ["Hatter Jiang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +lazy_static = "1.4.0" diff --git a/lazy_static/src/main.rs b/lazy_static/src/main.rs new file mode 100644 index 0000000..04f5393 --- /dev/null +++ b/lazy_static/src/main.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate lazy_static; + +lazy_static! { + static ref USER_HOME: Option = std::env::var("HOME").ok(); +} + +fn main() { + println!("User home: {:?}", *USER_HOME); +}