pub struct ItemStr { /* private fields */ }Expand description
This item is used to read an string value from the TOML file
Implementations§
Source§impl ItemStr
impl ItemStr
Sourcepub fn with_name<T: AsRef<str>>(name: T) -> ItemStr
pub fn with_name<T: AsRef<str>>(name: T) -> ItemStr
Constructs a new instance of the ItemUsize object.
Sourcepub fn add_to(self, group: &mut TomlDef) -> StringValue
pub fn add_to(self, group: &mut TomlDef) -> StringValue
Adds the item to a group and returns an option that will receive the item’s value when the file is loaded. Basically this allows a program to receive a value laoded from the file without getting the TomlData object that was created.
§Examples
use valid_toml::{TomlDef, ItemStr, ItemUsize};
let file = r#"
password = "secret"
count = 15
"#;
let mut def = TomlDef::new();
let password = ItemStr::with_name("password").min(3).max(8).add_to(&mut def);
let count = ItemUsize::with_name("count").optional().add_to(&mut def);
let file = def.parse_toml(file).unwrap();
assert_eq!(password.get(), "secret");
assert_eq!(count.get(), 15);Auto Trait Implementations§
impl Freeze for ItemStr
impl RefUnwindSafe for ItemStr
impl Send for ItemStr
impl Sync for ItemStr
impl Unpin for ItemStr
impl UnsafeUnpin for ItemStr
impl UnwindSafe for ItemStr
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