Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
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
You can’t perform that action at this time.