add lazy_static

This commit is contained in:
2020-01-30 22:15:35 +08:00
parent 2a21ef5743
commit 3c70fdf3b9
2 changed files with 20 additions and 0 deletions

10
lazy_static/Cargo.toml Normal file
View File

@@ -0,0 +1,10 @@
[package]
name = "lazy_static"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lazy_static = "1.4.0"

10
lazy_static/src/main.rs Normal file
View File

@@ -0,0 +1,10 @@
#[macro_use]
extern crate lazy_static;
lazy_static! {
static ref USER_HOME: Option<String> = std::env::var("HOME").ok();
}
fn main() {
println!("User home: {:?}", *USER_HOME);
}