fn string_or_table(&mut self) -> Result<(Value<'a>, Option<Cow<'a, str>>), Error> {
        match self.peek()? {
            Some((_, Token::LeftBracket)) => {
                let tables = self.tables()?;
                if tables.len() != 1 {
                    return Err(Error::from_kind(ErrorKind::Wanted {
                        expected: "exactly 1 table",
                        found: if tables.is_empty() {
                            "zero tables"
                        } else {
                            "more than 1 table"
                        },
                    }));
                }

                let table = tables
                    .into_iter()
                    .next()
                    .expect("Expected exactly one table");
                let header = table
                    .header
                    .last()
                    .expect("Expected at least one header value for table.");

                let start = table.at;
                let end = table
                    .values
                    .as_ref()
                    .and_then(|values| values.last())
                    .map(|&(_, ref val)| val.end)
                    .unwrap_or_else(|| header.len());
                Ok((
                    Value {
                        e: E::DottedTable(table.values.unwrap_or_else(Vec::new)),
                        start: start,
                        end: end,
                    },
                    Some(header.clone()),
                ))
            }
            Some(_) => self.value().map(|val| (val, None)),
            None => Err(self.eof()),
        }
    }
/// Returns a string or table value type.
///
/// Used to deserialize enums. Unit enums may be represented as a string or a table, all other
/// structures (tuple, newtype, struct) must be represented as a table.
Returns a string or table value type.
Used to deserialize enums. Unit enums may be represented as a string or a table, all other
structures (tuple, newtype, struct) must be represented as a table.
Returns a string or table value type . Used to deserialize enums . Unit enums may be represented as a string or a table all other structures ( tuple newtype struct ) must be represented as a table .
fn string_or_table(&mut self) -> Result<(Value<'a>, Option<Cow<'a, str>>), Error> {
        match self.peek()? {
            Some((_, Token::LeftBracket)) => {
                let tables = self.tables()?;
                if tables.len() != 1 {
                    return Err(Error::from_kind(ErrorKind::Wanted {
                        expected: "exactly 1 table",
                        found: if tables.is_empty() {
                            "zero tables"
                        } else {
                            "more than 1 table"
                        },
                    }));
                }
                let table = tables
                    .into_iter()
                    .next()
                    .expect("Expected exactly one table");
                let header = table
                    .header
                    .last()
                    .expect("Expected at least one header value for table.");
                let start = table.at;
                let end = table
                    .values
                    .as_ref()
                    .and_then(|values| values.last())
                    .map(|&(_, ref val)| val.end)
                    .unwrap_or_else(|| header.len());
                Ok((
                    Value {
                        e: E::DottedTable(table.values.unwrap_or_else(Vec::new)),
                        start: start,
                        end: end,
                    },
                    Some(header.clone()),
                ))
            }
            Some(_) => self.value().map(|val| (val, None)),
            None => Err(self.eof()),
        }
    }
fn string_or_table ( & mut self ) -> Result < ( Value < ' a > , Option < Cow < ' a , str > > ) , Error > { match self . peek ( ) ? { Some ( ( _ , Token :: LeftBracket ) ) => { let tables = self . tables ( ) ? ; if tables . len ( ) != 1 { return Err ( Error :: from_kind ( ErrorKind :: Wanted { expected : " " , found : if tables . is_empty ( ) { " " } else { " " } , } ) ) ; } let table = tables . into_iter ( ) . next ( ) . expect ( " " ) ; let header = table . header . last ( ) . expect ( " " ) ; let start = table . at ; let end = table . values . as_ref ( ) . and_then ( | values | values . last ( ) ) . map ( | & ( _ , ref val ) | val . end ) . unwrap_or_else ( | | header . len ( ) ) ; Ok ( ( Value { e : E :: DottedTable ( table . values . unwrap_or_else ( Vec :: new ) ) , start : start , end : end , } , Some ( header . clone ( ) ) , ) ) } Some ( _ ) => self . value ( ) . map ( | val | ( val , None ) ) , None => Err ( self . eof ( ) ) , } }
Returns a string or table value type.
Returns a string or table value type .
&mut self
&mut self