Created
January 24, 2020 16:02
-
-
Save rust-play/8ad6e24ebe1eb53aa92c0522b8c14261 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or 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
use lazy_static; // 1.4.0 | |
use std::collections::HashMap; | |
#[derive(Copy, Clone, Debug)] | |
pub struct Server {} | |
lazy_static::lazy_static! { | |
static ref SERVER1: Server = Server {}; | |
static ref SERVER2: Server = Server {}; | |
pub static ref RAW: HashMap<&'static str, &'static Server> = [ | |
("domain1.com", &*SERVER1), | |
("domain1.org", &*SERVER1), | |
("domain2.com", &*SERVER2), | |
].iter().copied().collect(); | |
} | |
fn main() { | |
let server = RAW.get("domain1.org"); | |
println!("{:?}", server); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment