Skip to content

Instantly share code, notes, and snippets.

@Enigo
Created February 1, 2023 03:54
Show Gist options
  • Save Enigo/1d5cf853d0d2ea6e1097f3d6a37437fa to your computer and use it in GitHub Desktop.
Save Enigo/1d5cf853d0d2ea6e1097f3d6a37437fa to your computer and use it in GitHub Desktop.
use std::env;
pub fn as_string(key: &str) -> String {
String::from(
env::var(key)
.expect(format!("{} should be set", key).as_str())
.as_str(),
)
}
pub fn as_u16(key: &str) -> u16 {
as_string(key)
.parse::<u16>()
.expect(format!("{} should be a valid u16", key).as_str())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment