diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime.rs | 22 | ||||
-rw-r--r-- | src/de.rs | 153 | ||||
-rw-r--r-- | src/map.rs | 4 | ||||
-rw-r--r-- | src/ser.rs | 75 | ||||
-rw-r--r-- | src/spanned.rs | 16 | ||||
-rw-r--r-- | src/tokens.rs | 13 | ||||
-rw-r--r-- | src/value.rs | 2 |
7 files changed, 133 insertions, 152 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 61eb3b1..683bbda 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -40,8 +40,8 @@ pub struct DatetimeParseError { // // In general the TOML encoder/decoder will catch this and not literally emit // these strings but rather emit datetimes as they're intended. -pub const FIELD: &'static str = "$__toml_private_datetime"; -pub const NAME: &'static str = "$__toml_private_Datetime"; +pub const FIELD: &str = "$__toml_private_datetime"; +pub const NAME: &str = "$__toml_private_Datetime"; #[derive(PartialEq, Clone)] struct Date { @@ -135,10 +135,10 @@ impl FromStr for Datetime { offset_allowed = false; None } else { - let y1 = digit(&mut chars)? as u16; - let y2 = digit(&mut chars)? as u16; - let y3 = digit(&mut chars)? as u16; - let y4 = digit(&mut chars)? as u16; + let y1 = u16::from(digit(&mut chars)?); + let y2 = u16::from(digit(&mut chars)?); + let y3 = u16::from(digit(&mut chars)?); + let y4 = u16::from(digit(&mut chars)?); match chars.next() { Some('-') => {} @@ -210,7 +210,7 @@ impl FromStr for Datetime { b'0'..=b'9' => { if i < 9 { let p = 10_u32.pow(8 - i as u32); - nanosecond += p * (byte - b'0') as u32; + nanosecond += p * u32::from(byte - b'0'); } } _ => { @@ -229,7 +229,7 @@ impl FromStr for Datetime { hour: h1 * 10 + h2, minute: m1 * 10 + m2, second: s1 * 10 + s2, - nanosecond: nanosecond, + nanosecond, }; if time.hour > 24 { @@ -292,8 +292,8 @@ impl FromStr for Datetime { Ok(Datetime { date: full_date, - time: time, - offset: offset, + time, + offset, }) } } @@ -345,7 +345,7 @@ impl<'de> de::Deserialize<'de> for Datetime { } } - static FIELDS: [&'static str; 1] = [FIELD]; + static FIELDS: [&str; 1] = [FIELD]; deserializer.deserialize_struct(NAME, &FIELDS, DatetimeVisitor) } } @@ -20,6 +20,9 @@ use crate::datetime; use crate::spanned; use crate::tokens::{Error as TokenError, Span, Token, Tokenizer}; +/// Type Alias for a TOML Table pair +type TablePair<'a> = (Cow<'a, str>, Value<'a>); + /// Deserializes a byte slice into a type. /// /// This function will attempt to interpret `bytes` as UTF-8 data and then @@ -270,9 +273,9 @@ impl<'de, 'b> de::Deserializer<'de> for &'b mut Deserializer<'de> { } E::DottedTable(_) => visitor.visit_enum(DottedTableDeserializer { name: name.expect("Expected table header to be passed."), - value: value, + value, }), - e @ _ => Err(Error::from_kind( + e => Err(Error::from_kind( Some(value.start), ErrorKind::Wanted { expected: "string or table", @@ -292,14 +295,14 @@ impl<'de, 'b> de::Deserializer<'de> for &'b mut Deserializer<'de> { struct Table<'a> { at: usize, header: Vec<Cow<'a, str>>, - values: Option<Vec<(Cow<'a, str>, Value<'a>)>>, + values: Option<Vec<TablePair<'a>>>, array: bool, } #[doc(hidden)] pub struct MapVisitor<'de, 'b> { - values: vec::IntoIter<(Cow<'de, str>, Value<'de>)>, - next_value: Option<(Cow<'de, str>, Value<'de>)>, + values: vec::IntoIter<TablePair<'de>>, + next_value: Option<TablePair<'de>>, depth: usize, cur: usize, cur_parent: usize, @@ -425,7 +428,7 @@ impl<'de, 'b> de::MapAccess<'de> for MapVisitor<'de, 'b> { cur_parent: self.cur - 1, cur: 0, max: self.max, - array: array, + array, tables: &mut *self.tables, de: &mut *self.de, }); @@ -525,7 +528,7 @@ struct StrDeserializer<'a> { impl<'a> StrDeserializer<'a> { fn new(key: Cow<'a, str>) -> StrDeserializer<'a> { - StrDeserializer { key: key } + StrDeserializer { key } } } @@ -557,7 +560,7 @@ struct ValueDeserializer<'a> { impl<'a> ValueDeserializer<'a> { fn new(value: Value<'a>) -> ValueDeserializer<'a> { ValueDeserializer { - value: value, + value, validate_struct_keys: false, } } @@ -615,7 +618,7 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> { where V: de::Visitor<'de>, { - if name == datetime::NAME && fields == &[datetime::FIELD] { + if name == datetime::NAME && fields == [datetime::FIELD] { if let E::Datetime(s) = self.value.e { return visitor.visit_map(DatetimeDeserializer { date: s, @@ -625,8 +628,8 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> { } if self.validate_struct_keys { - match &self.value.e { - &E::InlineTable(ref values) | &E::DottedTable(ref values) => { + match self.value.e { + E::InlineTable(ref values) | E::DottedTable(ref values) => { let extra_fields = values .iter() .filter_map(|key_value| { @@ -656,7 +659,7 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> { } } - if name == spanned::NAME && fields == &[spanned::START, spanned::END, spanned::VALUE] { + if name == spanned::NAME && fields == [spanned::START, spanned::END, spanned::VALUE] { let start = self.value.start; let end = self.value.end; @@ -710,7 +713,7 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> { }) } } - e @ _ => Err(Error::from_kind( + e => Err(Error::from_kind( Some(self.value.start), ErrorKind::Wanted { expected: "string or inline table", @@ -850,12 +853,12 @@ impl<'de> de::EnumAccess<'de> for DottedTableDeserializer<'de> { { let (name, value) = (self.name, self.value); seed.deserialize(StrDeserializer::new(name)) - .map(|val| (val, TableEnumDeserializer { value: value })) + .map(|val| (val, TableEnumDeserializer { value })) } } struct InlineTableDeserializer<'a> { - values: vec::IntoIter<(Cow<'a, str>, Value<'a>)>, + values: vec::IntoIter<TablePair<'a>>, next_value: Option<Value<'a>>, } @@ -905,7 +908,7 @@ impl<'de> de::EnumAccess<'de> for InlineTableDeserializer<'de> { }; seed.deserialize(StrDeserializer::new(key)) - .map(|val| (val, TableEnumDeserializer { value: value })) + .map(|val| (val, TableEnumDeserializer { value })) } } @@ -920,7 +923,7 @@ impl<'de> de::VariantAccess<'de> for TableEnumDeserializer<'de> { fn unit_variant(self) -> Result<(), Self::Error> { match self.value.e { E::InlineTable(values) | E::DottedTable(values) => { - if values.len() == 0 { + if values.is_empty() { Ok(()) } else { Err(Error::from_kind( @@ -929,7 +932,7 @@ impl<'de> de::VariantAccess<'de> for TableEnumDeserializer<'de> { )) } } - e @ _ => Err(Error::from_kind( + e => Err(Error::from_kind( Some(self.value.start), ErrorKind::Wanted { expected: "table", @@ -993,7 +996,7 @@ impl<'de> de::VariantAccess<'de> for TableEnumDeserializer<'de> { )) } } - e @ _ => Err(Error::from_kind( + e => Err(Error::from_kind( Some(self.value.start), ErrorKind::Wanted { expected: "table", @@ -1026,7 +1029,7 @@ impl<'a> Deserializer<'a> { pub fn new(input: &'a str) -> Deserializer<'a> { Deserializer { tokens: Tokenizer::new(input), - input: input, + input, require_newline_after_table: true, allow_duplciate_after_longer_table: false, } @@ -1080,10 +1083,10 @@ impl<'a> Deserializer<'a> { tables.push(cur_table); } cur_table = Table { - at: at, + at, header: Vec::new(), values: Some(Vec::new()), - array: array, + array, }; loop { let part = header.next().map_err(|e| self.token_error(e)); @@ -1151,7 +1154,7 @@ impl<'a> Deserializer<'a> { Ok(Line::Table { at: start, header: ret, - array: array, + array, }) } @@ -1175,33 +1178,33 @@ impl<'a> Deserializer<'a> { let value = match self.next()? { Some((Span { start, end }, Token::String { val, .. })) => Value { e: E::String(val), - start: start, - end: end, + start, + end, }, Some((Span { start, end }, Token::Keylike("true"))) => Value { e: E::Boolean(true), - start: start, - end: end, + start, + end, }, Some((Span { start, end }, Token::Keylike("false"))) => Value { e: E::Boolean(false), - start: start, - end: end, + start, + end, }, Some((span, Token::Keylike(key))) => self.number_or_date(span, key)?, Some((span, Token::Plus)) => self.number_leading_plus(span)?, Some((Span { start, .. }, Token::LeftBrace)) => { self.inline_table().map(|(Span { end, .. }, table)| Value { e: E::InlineTable(table), - start: start, - end: end, + start, + end, })? } Some((Span { start, .. }, Token::LeftBracket)) => { self.array().map(|(Span { end, .. }, array)| Value { e: E::Array(array), - start: start, - end: end, + start, + end, })? } Some(token) => { @@ -1226,15 +1229,15 @@ impl<'a> Deserializer<'a> { self.datetime(span, s, false) .map(|(Span { start, end }, d)| Value { e: E::Datetime(d), - start: start, - end: end, + start, + end, }) } else if self.eat(Token::Colon)? { self.datetime(span, s, true) .map(|(Span { start, end }, d)| Value { e: E::Datetime(d), - start: start, - end: end, + start, + end, }) } else { self.number(span, s) @@ -1282,8 +1285,8 @@ impl<'a> Deserializer<'a> { Ok(( Value { e: E::DottedTable(table.values.unwrap_or_else(Vec::new)), - start: start, - end: end, + start, + end, }, Some(header.clone()), )) @@ -1296,8 +1299,8 @@ impl<'a> Deserializer<'a> { fn number(&mut self, Span { start, end }: Span, s: &'a str) -> Result<Value<'a>, Error> { let to_integer = |f| Value { e: E::Integer(f), - start: start, - end: end, + start, + end, }; if s.starts_with("0x") { self.integer(&s[2..], 16).map(to_integer) @@ -1308,8 +1311,8 @@ impl<'a> Deserializer<'a> { } else if s.contains('e') || s.contains('E') { self.float(s, None).map(|f| Value { e: E::Float(f), - start: start, - end: end, + start, + end, }) } else if self.eat(Token::Period)? { let at = self.tokens.current(); @@ -1317,8 +1320,8 @@ impl<'a> Deserializer<'a> { Some((Span { start, end }, Token::Keylike(after))) => { self.float(s, Some(after)).map(|f| Value { e: E::Float(f), - start: start, - end: end, + start, + end, }) } _ => Err(self.error(at, ErrorKind::NumberInvalid)), @@ -1326,26 +1329,26 @@ impl<'a> Deserializer<'a> { } else if s == "inf" { Ok(Value { e: E::Float(f64::INFINITY), - start: start, - end: end, + start, + end, }) } else if s == "-inf" { Ok(Value { e: E::Float(f64::NEG_INFINITY), - start: start, - end: end, + start, + end, }) } else if s == "nan" { Ok(Value { e: E::Float(f64::NAN), - start: start, - end: end, + start, + end, }) } else if s == "-nan" { Ok(Value { e: E::Float(-f64::NAN), - start: start, - end: end, + start, + end, }) } else { self.integer(s, 10).map(to_integer) @@ -1355,13 +1358,7 @@ impl<'a> Deserializer<'a> { fn number_leading_plus(&mut self, Span { start, .. }: Span) -> Result<Value<'a>, Error> { let start_token = self.tokens.current(); match self.next()? { - Some((Span { end, .. }, Token::Keylike(s))) => self.number( - Span { - start: start, - end: end, - }, - s, - ), + Some((Span { end, .. }, Token::Keylike(s))) => self.number(Span { start, end }, s), _ => Err(self.error(start_token, ErrorKind::NumberInvalid)), } } @@ -1545,7 +1542,7 @@ impl<'a> Deserializer<'a> { // TODO(#140): shouldn't buffer up this entire table in memory, it'd be // great to defer parsing everything until later. - fn inline_table(&mut self) -> Result<(Span, Vec<(Cow<'a, str>, Value<'a>)>), Error> { + fn inline_table(&mut self) -> Result<(Span, Vec<TablePair<'a>>), Error> { let mut ret = Vec::new(); self.eat_whitespace()?; if let Some(span) = self.eat_spanned(Token::RightBrace)? { @@ -1641,7 +1638,7 @@ impl<'a> Deserializer<'a> { &self, mut key_parts: Vec<Cow<'a, str>>, value: Value<'a>, - values: &mut Vec<(Cow<'a, str>, Value<'a>)>, + values: &mut Vec<TablePair<'a>>, ) -> Result<(), Error> { let key = key_parts.remove(0); if key_parts.is_empty() { @@ -1752,13 +1749,7 @@ impl<'a> Deserializer<'a> { at, expected, found, - } => self.error( - at, - ErrorKind::Wanted { - expected: expected, - found: found, - }, - ), + } => self.error(at, ErrorKind::Wanted { expected, found }), TokenError::EmptyTableKey(at) => self.error(at, ErrorKind::EmptyTableKey), TokenError::MultilineStringKey(at) => self.error(at, ErrorKind::MultilineStringKey), } @@ -1799,7 +1790,7 @@ impl Error { fn from_kind(at: Option<usize>, kind: ErrorKind) -> Error { Error { inner: Box::new(ErrorInner { - kind: kind, + kind, line: None, col: 0, at, @@ -1829,7 +1820,7 @@ impl Error { self.inner.key.insert(0, key.to_string()); } - fn fix_offset<F>(&mut self, f: F) -> () + fn fix_offset<F>(&mut self, f: F) where F: FnOnce() -> Option<usize>, { @@ -1840,7 +1831,7 @@ impl Error { } } - fn fix_linecol<F>(&mut self, f: F) -> () + fn fix_linecol<F>(&mut self, f: F) where F: FnOnce(usize) -> (usize, usize), { @@ -1854,7 +1845,7 @@ impl Error { impl std::convert::From<Error> for std::io::Error { fn from(e: Error) -> Self { - return std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()); + std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()) } } @@ -1995,9 +1986,9 @@ impl<'a> Header<'a> { fn new(tokens: Tokenizer<'a>, array: bool, require_newline_after_table: bool) -> Header<'a> { Header { first: true, - array: array, - tokens: tokens, - require_newline_after_table: require_newline_after_table, + array, + tokens, + require_newline_after_table, } } @@ -2015,10 +2006,8 @@ impl<'a> Header<'a> { } self.tokens.eat_whitespace()?; - if self.require_newline_after_table { - if !self.tokens.eat_comment()? { - self.tokens.eat_newline_or_eof()?; - } + if self.require_newline_after_table && !self.tokens.eat_comment()? { + self.tokens.eat_newline_or_eof()?; } Ok(None) } @@ -2040,8 +2029,8 @@ enum E<'a> { String(Cow<'a, str>), Datetime(&'a str), Array(Vec<Value<'a>>), - InlineTable(Vec<(Cow<'a, str>, Value<'a>)>), - DottedTable(Vec<(Cow<'a, str>, Value<'a>)>), + InlineTable(Vec<TablePair<'a>>), + DottedTable(Vec<TablePair<'a>>), } impl<'a> E<'a> { @@ -150,8 +150,8 @@ impl Map<String, Value> { use std::collections::btree_map::Entry as EntryImpl; match self.map.entry(key.into()) { - EntryImpl::Vacant(vacant) => Entry::Vacant(VacantEntry { vacant: vacant }), - EntryImpl::Occupied(occupied) => Entry::Occupied(OccupiedEntry { occupied: occupied }), + EntryImpl::Vacant(vacant) => Entry::Vacant(VacantEntry { vacant }), + EntryImpl::Occupied(occupied) => Entry::Occupied(OccupiedEntry { occupied }), } } @@ -247,7 +247,7 @@ impl<'a> Serializer<'a> { /// will be present in `dst`. pub fn new(dst: &'a mut String) -> Serializer<'a> { Serializer { - dst: dst, + dst, state: State::End, settings: Rc::new(Settings::default()), } @@ -263,7 +263,7 @@ impl<'a> Serializer<'a> { /// have a trailing comma. See `Serializer::pretty_array` pub fn pretty(dst: &'a mut String) -> Serializer<'a> { Serializer { - dst: dst, + dst, state: State::End, settings: Rc::new(Settings { array: Some(ArraySettings::pretty()), @@ -331,13 +331,12 @@ impl<'a> Serializer<'a> { /// """ /// ``` pub fn pretty_string_literal(&mut self, value: bool) -> &mut Self { - let use_default = - if let &mut Some(ref mut s) = &mut Rc::get_mut(&mut self.settings).unwrap().string { - s.literal = value; - false - } else { - true - }; + let use_default = if let Some(ref mut s) = Rc::get_mut(&mut self.settings).unwrap().string { + s.literal = value; + false + } else { + true + }; if use_default { let mut string = StringSettings::pretty(); @@ -387,13 +386,12 @@ impl<'a> Serializer<'a> { /// /// See `Serializer::pretty_array` for more details. pub fn pretty_array_indent(&mut self, value: usize) -> &mut Self { - let use_default = - if let &mut Some(ref mut a) = &mut Rc::get_mut(&mut self.settings).unwrap().array { - a.indent = value; - false - } else { - true - }; + let use_default = if let Some(ref mut a) = Rc::get_mut(&mut self.settings).unwrap().array { + a.indent = value; + false + } else { + true + }; if use_default { let mut array = ArraySettings::pretty(); @@ -407,13 +405,12 @@ impl<'a> Serializer<'a> { /// /// See `Serializer::pretty_array` for more details. pub fn pretty_array_trailing_comma(&mut self, value: bool) -> &mut Self { - let use_default = - if let &mut Some(ref mut a) = &mut Rc::get_mut(&mut self.settings).unwrap().array { - a.trailing_comma = value; - false - } else { - true - }; + let use_default = if let Some(ref mut a) = Rc::get_mut(&mut self.settings).unwrap().array { + a.trailing_comma = value; + false + } else { + true + }; if use_default { let mut array = ArraySettings::pretty(); @@ -425,7 +422,7 @@ impl<'a> Serializer<'a> { fn display<T: fmt::Display>(&mut self, t: T, type_: &'static str) -> Result<(), Error> { self.emit_key(type_)?; - drop(write!(self.dst, "{}", t)); + write!(self.dst, "{}", t).map_err(ser::Error::custom)?; if let State::Table { .. } = self.state { self.dst.push_str("\n"); } @@ -518,7 +515,7 @@ impl<'a> Serializer<'a> { _ => false, }); if ok { - drop(write!(self.dst, "{}", key)); + write!(self.dst, "{}", key).map_err(ser::Error::custom)?; } else { self.emit_str(key, true)?; } @@ -610,7 +607,7 @@ impl<'a> Serializer<'a> { (&Some(StringSettings { literal: false, .. }), Repr::Literal(_, ty)) => { Repr::Std(ty) } - (_, r @ _) => r, + (_, r) => r, } } else { Repr::Std(Type::OnelineSingle) @@ -650,7 +647,9 @@ impl<'a> Serializer<'a> { '\u{d}' => self.dst.push_str("\\r"), '\u{22}' => self.dst.push_str("\\\""), '\u{5c}' => self.dst.push_str("\\\\"), - c if c < '\u{1f}' => drop(write!(self.dst, "\\u{:04X}", ch as u32)), + c if c < '\u{1f}' => { + write!(self.dst, "\\u{:04X}", ch as u32).map_err(ser::Error::custom)?; + } ch => self.dst.push(ch), } } @@ -753,15 +752,15 @@ macro_rules! serialize_float { ($this:expr, $v:expr) => {{ $this.emit_key("float")?; if ($v.is_nan() || $v == 0.0) && $v.is_sign_negative() { - drop(write!($this.dst, "-")); + write!($this.dst, "-").map_err(ser::Error::custom)?; } if $v.is_nan() { - drop(write!($this.dst, "nan")); + write!($this.dst, "nan").map_err(ser::Error::custom)?; } else { - drop(write!($this.dst, "{}", $v)); + write!($this.dst, "{}", $v).map_err(ser::Error::custom)?; } if $v % 1.0 == 0.0 { - drop(write!($this.dst, ".0")); + write!($this.dst, ".0").map_err(ser::Error::custom)?; } if let State::Table { .. } = $this.state { $this.dst.push_str("\n"); @@ -902,7 +901,7 @@ impl<'a, 'b> ser::Serializer for &'b mut Serializer<'a> { ser: self, first: Cell::new(true), type_: Cell::new(None), - len: len, + len, }) } @@ -1099,10 +1098,10 @@ impl<'a, 'b> ser::SerializeMap for SerializeTable<'a, 'b> { let res = value.serialize(&mut Serializer { dst: &mut *ser.dst, state: State::Table { - key: key, + key, parent: &ser.state, - first: first, - table_emitted: table_emitted, + first, + table_emitted, }, settings: ser.settings.clone(), }); @@ -1155,10 +1154,10 @@ impl<'a, 'b> ser::SerializeStruct for SerializeTable<'a, 'b> { let res = value.serialize(&mut Serializer { dst: &mut *ser.dst, state: State::Table { - key: key, + key, parent: &ser.state, - first: first, - table_emitted: table_emitted, + first, + table_emitted, }, settings: ser.settings.clone(), }); diff --git a/src/spanned.rs b/src/spanned.rs index d9fec3a..f2fc180 100644 --- a/src/spanned.rs +++ b/src/spanned.rs @@ -2,13 +2,13 @@ use serde::{de, ser}; use std::fmt; #[doc(hidden)] -pub const NAME: &'static str = "$__toml_private_Spanned"; +pub const NAME: &str = "$__toml_private_Spanned"; #[doc(hidden)] -pub const START: &'static str = "$__toml_private_start"; +pub const START: &str = "$__toml_private_start"; #[doc(hidden)] -pub const END: &'static str = "$__toml_private_end"; +pub const END: &str = "$__toml_private_end"; #[doc(hidden)] -pub const VALUE: &'static str = "$__toml_private_value"; +pub const VALUE: &str = "$__toml_private_value"; /// A spanned value, indicating the range at which it is defined in the source. /// @@ -116,17 +116,13 @@ where let value: T = visitor.next_value()?; - Ok(Spanned { - start: start, - end: end, - value: value, - }) + Ok(Spanned { start, end, value }) } } let visitor = SpannedVisitor(::std::marker::PhantomData); - static FIELDS: [&'static str; 3] = [START, END, VALUE]; + static FIELDS: [&str; 3] = [START, END, VALUE]; deserializer.deserialize_struct(NAME, &FIELDS, visitor) } } diff --git a/src/tokens.rs b/src/tokens.rs index f9d3eb4..91824c5 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -84,7 +84,7 @@ enum MaybeString { impl<'a> Tokenizer<'a> { pub fn new(input: &'a str) -> Tokenizer<'a> { let mut t = Tokenizer { - input: input, + input, chars: CrlfFold { chars: input.char_indices(), }, @@ -266,7 +266,7 @@ impl<'a> Tokenizer<'a> { .clone() .next() .map(|i| i.0) - .unwrap_or(self.input.len()) + .unwrap_or_else(|| self.input.len()) } pub fn input(&self) -> &'a str { @@ -349,7 +349,7 @@ impl<'a> Tokenizer<'a> { return Ok(String { src: &self.input[start..self.current()], val: val.into_cow(&self.input[..i]), - multiline: multiline, + multiline, }); } Some((i, c)) => new_ch(self, &mut val, multiline, i, c)?, @@ -463,10 +463,7 @@ impl<'a> Tokenizer<'a> { .peek_one() .map(|t| t.0) .unwrap_or_else(|| self.input.len()); - Span { - start: start, - end: end, - } + Span { start, end } } /// Peek one char without consuming it. @@ -642,7 +639,7 @@ mod tests { err(r#""\U00""#, Error::InvalidHexEscape(5, '"')); err(r#""\U00"#, Error::UnterminatedString(0)); err(r#""\uD800"#, Error::InvalidEscapeValue(2, 0xd800)); - err(r#""\UFFFFFFFF"#, Error::InvalidEscapeValue(2, 0xffffffff)); + err(r#""\UFFFFFFFF"#, Error::InvalidEscapeValue(2, 0xffff_ffff)); } #[test] diff --git a/src/value.rs b/src/value.rs index 6f940b4..38dfe1f 100644 --- a/src/value.rs +++ b/src/value.rs @@ -749,7 +749,7 @@ impl ser::Serializer for Serializer { } fn serialize_i64(self, value: i64) -> Result<Value, crate::ser::Error> { - Ok(Value::Integer(value.into())) + Ok(Value::Integer(value)) } fn serialize_u8(self, value: u8) -> Result<Value, crate::ser::Error> { |