Struct jrsonnet_cli::ExtStr
source · pub struct ExtStr {
pub name: String,
pub value: String,
}
Fields§
§name: String
§value: String
Trait Implementations§
source§impl FromStr for ExtStr
impl FromStr for ExtStr
Parses a string like name=<value>
, or name
and reads value from env variable.
With no value it will be read from env variable.
If env variable is not found then it will be an error.
Value can contain =
symbol.
use std::str::FromStr;
use jrsonnet_cli::ExtStr;
let ext = ExtStr::from_str("name=value").unwrap();
assert_eq!(ext.name, "name");
assert_eq!(ext.value, "value");
std::env::set_var("name", "value");
let ext = ExtStr::from_str("name").unwrap();
assert_eq!(ext.name, "name");
assert_eq!(ext.value, "value");
let ext = ExtStr::from_str("name=value=with=equals").unwrap();
assert_eq!(ext.name, "name");
assert_eq!(ext.value, "value=with=equals");
Auto Trait Implementations§
impl RefUnwindSafe for ExtStr
impl Send for ExtStr
impl Sync for ExtStr
impl Unpin for ExtStr
impl UnwindSafe for ExtStr
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more