pub struct Dictionary<'a> { /* private fields */ }Expand description
A validated Dictionary. Every member is kept in order; a repeated key’s
last value wins in get and index_into.
Implementations§
Source§impl<'a> Dictionary<'a>
impl<'a> Dictionary<'a>
Sourcepub fn index_into<'i>(
&self,
slots: &'i mut [(&'a str, Member<'a>)],
) -> Result<&'i [(&'a str, Member<'a>)], ParseError>
pub fn index_into<'i>( &self, slots: &'i mut [(&'a str, Member<'a>)], ) -> Result<&'i [(&'a str, Member<'a>)], ParseError>
Fills slots with one entry per distinct key (the last value for a
repeated key), in first-seen order, and returns the filled part: for
callers that look up many keys.
§Errors
ErrorKind::BufferTooSmall when there are more distinct keys than
slots.
§Examples
use parse_net::sfv::{self, BareItem, Item, Member};
let d = sfv::parse_dictionary(b"a=1, b=2, a=3")?;
let mut slots = [("", Member::Item(Item::new(BareItem::Boolean(false)))); 4];
let index = d.index_into(&mut slots)?;
assert_eq!(index.len(), 2);
assert!(matches!(index[0], ("a", Member::Item(i)) if i.bare == BareItem::Integer(3)));Trait Implementations§
Source§impl<'a> Clone for Dictionary<'a>
impl<'a> Clone for Dictionary<'a>
impl<'a> Copy for Dictionary<'a>
Source§impl<'a> Debug for Dictionary<'a>
impl<'a> Debug for Dictionary<'a>
impl<'a> Eq for Dictionary<'a>
Source§impl<'a> Hash for Dictionary<'a>
impl<'a> Hash for Dictionary<'a>
Source§impl<'a> PartialEq for Dictionary<'a>
impl<'a> PartialEq for Dictionary<'a>
impl<'a> StructuralPartialEq for Dictionary<'a>
Auto Trait Implementations§
impl<'a> Freeze for Dictionary<'a>
impl<'a> RefUnwindSafe for Dictionary<'a>
impl<'a> Send for Dictionary<'a>
impl<'a> Sync for Dictionary<'a>
impl<'a> Unpin for Dictionary<'a>
impl<'a> UnsafeUnpin for Dictionary<'a>
impl<'a> UnwindSafe for Dictionary<'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