Safest way to make a serde_json result globally avaialable [duplicate]
问题 This question already has answers here : How do I create a global, mutable singleton? (3 answers) Is it possible to use global variables in Rust? (5 answers) Closed 18 days ago . What is a safe way to make a serde_json result globally available in rust? For instance I have a pub function in a module that contains let contents = fs::read_to_string(json_file_path).expect("file not found"); let myVar: Foo = match serde_json::from_str(&contents){ ...} println!("WIDTH:{}", myVar.Output.width);