macro_rules! parse_or_warn {
($s:expr, $ty:ty, $default:expr, $context:expr) => { ... };
}Expand description
Parse a string into a type, returning a default and logging on failure.
Drop-in replacement for str.parse::<T>().unwrap().
§Examples
use unwrap_safe::parse_or_warn;
let port = parse_or_warn!("not_a_number", u16, 8080, "PORT config");
assert_eq!(port, 8080);
let port = parse_or_warn!("3000", u16, 8080, "PORT config");
assert_eq!(port, 3000);