fn add_dotted_key(
        &self,
        mut key_parts: Vec<Cow<'a, str>>,
        value: Value<'a>,
        values: &mut Vec<(Cow<'a, str>, Value<'a>)>,
    ) -> Result<(), Error> {
        let key = key_parts.remove(0);
        if key_parts.is_empty() {
            values.push((key, value));
            return Ok(());
        }
        match values.iter_mut().find(|&&mut (ref k, _)| *k == key) {
            Some(&mut (_, Value { e: E::DottedTable(ref mut v), .. })) => {
                return self.add_dotted_key(key_parts, value, v);
            }
            Some(&mut (_, Value { start, .. })) => {
                return Err(self.error(start, ErrorKind::DottedKeyInvalidType));
            }
            None => {}
        }
        // The start/end value is somewhat misleading here.
        let table_values = Value {
            e: E::DottedTable(Vec::new()),
            start: value.start,
            end: value.end,
        };
        values.push((key, table_values));
        let last_i = values.len() - 1;
        if let (_, Value { e: E::DottedTable(ref mut v), .. }) = values[last_i] {
            self.add_dotted_key(key_parts, value, v)?;
        }
        Ok(())
    }
/// Stores a value in the appropriate hierachical structure positioned based on the dotted key.
///
/// Given the following definition: `multi.part.key = "value"`, `multi` and `part` are
/// intermediate parts which are mapped to the relevant fields in the deserialized type's data
/// hierarchy.
///
/// # Parameters
///
/// * `key_parts`: Each segment of the dotted key, e.g. `part.one` maps to
///                `vec![Cow::Borrowed("part"), Cow::Borrowed("one")].`
/// * `value`: The parsed value.
/// * `values`: The `Vec` to store the value in.
Stores a value in the appropriate hierachical structure positioned based on the dotted key.
Stores a value in the appropriate hierachical structure positioned based on the dotted key .
fn add_dotted_key(
        &self,
        mut key_parts: Vec<Cow<'a, str>>,
        value: Value<'a>,
        values: &mut Vec<(Cow<'a, str>, Value<'a>)>,
    ) -> Result<(), Error> {
        let key = key_parts.remove(0);
        if key_parts.is_empty() {
            values.push((key, value));
            return Ok(());
        }
        match values.iter_mut().find(|&&mut (ref k, _)| *k == key) {
            Some(&mut (_, Value { e: E::DottedTable(ref mut v), .. })) => {
                return self.add_dotted_key(key_parts, value, v);
            }
            Some(&mut (_, Value { start, .. })) => {
                return Err(self.error(start, ErrorKind::DottedKeyInvalidType));
            }
            None => {}
        }
        // The start/end value is somewhat misleading here.
        let table_values = Value {
            e: E::DottedTable(Vec::new()),
            start: value.start,
            end: value.end,
        };
        values.push((key, table_values));
        let last_i = values.len() - 1;
        if let (_, Value { e: E::DottedTable(ref mut v), .. }) = values[last_i] {
            self.add_dotted_key(key_parts, value, v)?;
        }
        Ok(())
    }
fn add_dotted_key ( & self , mut key_parts : Vec < Cow < ' a , str > > , value : Value < ' a > , values : & mut Vec < ( Cow < ' a , str > , Value < ' a > ) > , ) -> Result < ( ) , Error > { let key = key_parts . remove ( 0 ) ; if key_parts . is_empty ( ) { values . push ( ( key , value ) ) ; return Ok ( ( ) ) ; } match values . iter_mut ( ) . find ( | & & mut ( ref k , _ ) | * k == key ) { Some ( & mut ( _ , Value { e : E :: DottedTable ( ref mut v ) , .. } ) ) => { return self . add_dotted_key ( key_parts , value , v ) ; } Some ( & mut ( _ , Value { start , .. } ) ) => { return Err ( self . error ( start , ErrorKind :: DottedKeyInvalidType ) ) ; } None => { } } // The start/end value is somewhat misleading here. let table_values = Value { e : E :: DottedTable ( Vec :: new ( ) ) , start : value . start , end : value . end , } ; values . push ( ( key , table_values ) ) ; let last_i = values . len ( ) - 1 ; if let ( _ , Value { e : E :: DottedTable ( ref mut v ) , .. } ) = values [ last_i ] { self . add_dotted_key ( key_parts , value , v ) ? ; } Ok ( ( ) ) }
Stores a value in the appropriate hierachical structure positioned based on the dotted key.
Stores a value in the appropriate hierachical structure positioned based on the dotted key .
&self
key_parts
Vec<Cow<'a, str>>
value
Value<'a>
values
&mut Vec<(Cow<'a, str>, Value<'a>)>
&self
key_parts
Vec<Cow<'a, str>>
value
Value<'a>
values
&mut Vec<(Cow<'a, str>, Value<'a>)>