summaryrefslogtreecommitdiffstats
path: root/third_party/rust/serde/src
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/serde/src')
-rw-r--r--third_party/rust/serde/src/de/mod.rs61
-rw-r--r--third_party/rust/serde/src/de/value.rs4
-rw-r--r--third_party/rust/serde/src/lib.rs15
3 files changed, 57 insertions, 23 deletions
diff --git a/third_party/rust/serde/src/de/mod.rs b/third_party/rust/serde/src/de/mod.rs
index c9919d92b8..1924fe3d88 100644
--- a/third_party/rust/serde/src/de/mod.rs
+++ b/third_party/rust/serde/src/de/mod.rs
@@ -402,20 +402,20 @@ impl<'a> fmt::Display for Unexpected<'a> {
Bool(b) => write!(formatter, "boolean `{}`", b),
Unsigned(i) => write!(formatter, "integer `{}`", i),
Signed(i) => write!(formatter, "integer `{}`", i),
- Float(f) => write!(formatter, "floating point `{}`", f),
+ Float(f) => write!(formatter, "floating point `{}`", WithDecimalPoint(f)),
Char(c) => write!(formatter, "character `{}`", c),
Str(s) => write!(formatter, "string {:?}", s),
- Bytes(_) => write!(formatter, "byte array"),
- Unit => write!(formatter, "unit value"),
- Option => write!(formatter, "Option value"),
- NewtypeStruct => write!(formatter, "newtype struct"),
- Seq => write!(formatter, "sequence"),
- Map => write!(formatter, "map"),
- Enum => write!(formatter, "enum"),
- UnitVariant => write!(formatter, "unit variant"),
- NewtypeVariant => write!(formatter, "newtype variant"),
- TupleVariant => write!(formatter, "tuple variant"),
- StructVariant => write!(formatter, "struct variant"),
+ Bytes(_) => formatter.write_str("byte array"),
+ Unit => formatter.write_str("unit value"),
+ Option => formatter.write_str("Option value"),
+ NewtypeStruct => formatter.write_str("newtype struct"),
+ Seq => formatter.write_str("sequence"),
+ Map => formatter.write_str("map"),
+ Enum => formatter.write_str("enum"),
+ UnitVariant => formatter.write_str("unit variant"),
+ NewtypeVariant => formatter.write_str("newtype variant"),
+ TupleVariant => formatter.write_str("tuple variant"),
+ StructVariant => formatter.write_str("struct variant"),
Other(other) => formatter.write_str(other),
}
}
@@ -2278,10 +2278,10 @@ impl Display for OneOf {
1 => write!(formatter, "`{}`", self.names[0]),
2 => write!(formatter, "`{}` or `{}`", self.names[0], self.names[1]),
_ => {
- tri!(write!(formatter, "one of "));
+ tri!(formatter.write_str("one of "));
for (i, alt) in self.names.iter().enumerate() {
if i > 0 {
- tri!(write!(formatter, ", "));
+ tri!(formatter.write_str(", "));
}
tri!(write!(formatter, "`{}`", alt));
}
@@ -2290,3 +2290,36 @@ impl Display for OneOf {
}
}
}
+
+struct WithDecimalPoint(f64);
+
+impl Display for WithDecimalPoint {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ struct LookForDecimalPoint<'f, 'a> {
+ formatter: &'f mut fmt::Formatter<'a>,
+ has_decimal_point: bool,
+ }
+
+ impl<'f, 'a> fmt::Write for LookForDecimalPoint<'f, 'a> {
+ fn write_str(&mut self, fragment: &str) -> fmt::Result {
+ self.has_decimal_point |= fragment.contains('.');
+ self.formatter.write_str(fragment)
+ }
+
+ fn write_char(&mut self, ch: char) -> fmt::Result {
+ self.has_decimal_point |= ch == '.';
+ self.formatter.write_char(ch)
+ }
+ }
+
+ let mut writer = LookForDecimalPoint {
+ formatter,
+ has_decimal_point: false,
+ };
+ tri!(write!(writer, "{}", self.0));
+ if !writer.has_decimal_point {
+ tri!(formatter.write_str(".0"));
+ }
+ Ok(())
+ }
+}
diff --git a/third_party/rust/serde/src/de/value.rs b/third_party/rust/serde/src/de/value.rs
index b229ebab77..3bc0c71c57 100644
--- a/third_party/rust/serde/src/de/value.rs
+++ b/third_party/rust/serde/src/de/value.rs
@@ -983,7 +983,7 @@ struct ExpectedInSeq(usize);
impl Expected for ExpectedInSeq {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if self.0 == 1 {
- write!(formatter, "1 element in sequence")
+ formatter.write_str("1 element in sequence")
} else {
write!(formatter, "{} elements in sequence", self.0)
}
@@ -1411,7 +1411,7 @@ struct ExpectedInMap(usize);
impl Expected for ExpectedInMap {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if self.0 == 1 {
- write!(formatter, "1 element in map")
+ formatter.write_str("1 element in map")
} else {
write!(formatter, "{} elements in map", self.0)
}
diff --git a/third_party/rust/serde/src/lib.rs b/third_party/rust/serde/src/lib.rs
index b0756af6dc..5cf44c1c18 100644
--- a/third_party/rust/serde/src/lib.rs
+++ b/third_party/rust/serde/src/lib.rs
@@ -95,7 +95,7 @@
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.195")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.197")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Show which crate feature enables conditionally compiled APIs in documentation.
@@ -130,6 +130,7 @@
clippy::derive_partial_eq_without_eq,
clippy::enum_glob_use,
clippy::explicit_auto_deref,
+ clippy::incompatible_msrv,
clippy::let_underscore_untyped,
clippy::map_err_ignore,
clippy::new_without_default,
@@ -178,16 +179,16 @@ mod lib {
pub use self::core::{cmp, mem, slice};
pub use self::core::cell::{Cell, RefCell};
- pub use self::core::clone::{self, Clone};
+ pub use self::core::clone;
pub use self::core::cmp::Reverse;
- pub use self::core::convert::{self, From, Into};
- pub use self::core::default::{self, Default};
- pub use self::core::fmt::{self, Debug, Display};
+ pub use self::core::convert;
+ pub use self::core::default;
+ pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite};
pub use self::core::marker::{self, PhantomData};
pub use self::core::num::Wrapping;
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
- pub use self::core::option::{self, Option};
- pub use self::core::result::{self, Result};
+ pub use self::core::option;
+ pub use self::core::result;
pub use self::core::time::Duration;
#[cfg(all(feature = "alloc", not(feature = "std")))]