pub struct DictionaryLines<'a> { /* private fields */ }Expand description
Several field lines read as one Dictionary.
§Examples
use parse_net::sfv::{self, BareItem, Member};
let lines: [&[u8]; 2] = [b"a=1", b"b=2, a=3"];
let d = sfv::parse_dictionary_lines(&lines)?;
assert_eq!(d.len(), 3);
assert!(matches!(d.get("a"), Some(Member::Item(i)) if i.bare == BareItem::Integer(3)));Implementations§
Source§impl<'a> DictionaryLines<'a>
impl<'a> DictionaryLines<'a>
Sourcepub fn iter(&self) -> impl Iterator<Item = (&'a str, Member<'a>)> + use<'a>
pub fn iter(&self) -> impl Iterator<Item = (&'a str, Member<'a>)> + use<'a>
The members of every line, in order.
§Examples
let lines: [&[u8]; 2] = [b"a=1", b"b=2, a=3"];
let d = parse_net::sfv::parse_dictionary_lines(&lines)?;
assert!(d.iter().map(|(k, _)| k).eq(["a", "b", "a"]));Sourcepub fn get(&self, key: &str) -> Option<Member<'a>>
pub fn get(&self, key: &str) -> Option<Member<'a>>
The member for key: the last occurrence across every line.
§Examples
use parse_net::sfv::{self, BareItem, Member};
let lines: [&[u8]; 2] = [b"a=1, b", b"a=2"];
let d = sfv::parse_dictionary_lines(&lines)?;
assert!(matches!(d.get("a"), Some(Member::Item(i)) if i.bare == BareItem::Integer(2)));
assert!(d.get("c").is_none());Trait Implementations§
Source§impl<'a> Clone for DictionaryLines<'a>
impl<'a> Clone for DictionaryLines<'a>
impl<'a> Copy for DictionaryLines<'a>
Auto Trait Implementations§
impl<'a> Freeze for DictionaryLines<'a>
impl<'a> RefUnwindSafe for DictionaryLines<'a>
impl<'a> Send for DictionaryLines<'a>
impl<'a> Sync for DictionaryLines<'a>
impl<'a> Unpin for DictionaryLines<'a>
impl<'a> UnsafeUnpin for DictionaryLines<'a>
impl<'a> UnwindSafe for DictionaryLines<'a>
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