summaryrefslogtreecommitdiffstats
path: root/third_party/rust/serde
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/serde
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/serde')
-rw-r--r--third_party/rust/serde/.cargo-checksum.json2
-rw-r--r--third_party/rust/serde/Cargo.toml4
-rw-r--r--third_party/rust/serde/build.rs6
-rw-r--r--third_party/rust/serde/src/de/impls.rs119
-rw-r--r--third_party/rust/serde/src/de/mod.rs8
-rw-r--r--third_party/rust/serde/src/lib.rs5
-rw-r--r--third_party/rust/serde/src/private/de.rs7
-rw-r--r--third_party/rust/serde/src/private/doc.rs5
-rw-r--r--third_party/rust/serde/src/private/ser.rs132
-rw-r--r--third_party/rust/serde/src/ser/fmt.rs16
-rw-r--r--third_party/rust/serde/src/ser/impls.rs51
-rw-r--r--third_party/rust/serde/src/ser/impossible.rs32
-rw-r--r--third_party/rust/serde/src/ser/mod.rs79
13 files changed, 291 insertions, 175 deletions
diff --git a/third_party/rust/serde/.cargo-checksum.json b/third_party/rust/serde/.cargo-checksum.json
index d55068bd63..65bca8af82 100644
--- a/third_party/rust/serde/.cargo-checksum.json
+++ b/third_party/rust/serde/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"f03b626efae73a6dd42f07d722dad2da3a4add51f4e653e30a6d696853bab209","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","build.rs":"f9ba30324b9ce085c903595fb55a5293f8c2348ff36bfe870521b935ae6d105c","crates-io.md":"56e988ac4944c45f5bf5051e3827892ed8fb817853d99d9df1fff6621108e270","src/de/format.rs":"c85071b016df643b161859682d21ce34fa0ebf2a3bdbeeea69859da48f5d934f","src/de/ignored_any.rs":"6480f2b2a83dc4764d01b2eec7309729eef2492eede2e5ee98d23a60b05198eb","src/de/impls.rs":"2857d734176a0b78a41c9358354b0b0b83c6b2d948590be072d98606a8cae9d6","src/de/mod.rs":"fc34da49f692803d2c2f131322d9b48ad8e4f39ed10b2b304d6193ab09d621fb","src/de/seed.rs":"045d890712a04eb33ffc5a021e5d948a63c89402b8ffeea749df2171b7484f8f","src/de/size_hint.rs":"fff83dc39d30e75e8e611991f9c5399188a1aad23a6462dbca2c8b62655cfedb","src/de/value.rs":"0fd511a288c20a1b768718f4baadf9c7d4146d276af6a71ba1d0f7679b28644a","src/integer128.rs":"29ef30b7d94507b34807090e68173767cdc7aff62edccd38affe69e75338dddc","src/lib.rs":"638b231a280519f1861ea5f1bfbe97e2394b2f7662a9701b8e57ed95093dd298","src/macros.rs":"e3486ef4a9a4ed1b27234aa1817ccb25ec0eb026ffc95e2c71c7b917f1f45629","src/private/de.rs":"6557a124fdaf61f9c7cd80163e40f4a453354e45b63a4eb55dafdfe0159f6881","src/private/doc.rs":"9ad740e9ea2eedf861b77116eda9a6fb74bc8553541cd17d1bc5791a3ef3271a","src/private/mod.rs":"b8f0c348621d91dd9da3db83d8877e70bc61ad0a2dc2d6fb57c6fc2c2cbafa26","src/private/ser.rs":"656613691bd8d40cb70a52d4ebe3ee96a993c8a1292d50822d9ca5bdad84426b","src/ser/fmt.rs":"77a5583e5c227ea1982b097ed6378af5c899d43761d71e33440262fd35944695","src/ser/impls.rs":"850619164b399c37cd373d24f5a2c83453f40b34bb978c5722d2c1ae226775b5","src/ser/impossible.rs":"e11b37689ec1395378d546fce74221ca9046d0761744301f12029102fd07e30e","src/ser/mod.rs":"a7fd082203d63cbe4f0fe86d9be16bf4f3b2444653dac6bb61d82e0f4f6b4214","src/std_error.rs":"25a07149e2e468747ffa5a58051c7f93d7b3c0fa0372f012a96c97ec8ab03b97"},"package":"3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"} \ No newline at end of file
+{"files":{"Cargo.toml":"fcf211f4e710da1375e944a42621a8cd3de8d683db3e464ab570652216015d87","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","build.rs":"56b4f43d4061c03fbdd4f6325f30439686b12679bace304223d30c03632a925e","crates-io.md":"56e988ac4944c45f5bf5051e3827892ed8fb817853d99d9df1fff6621108e270","src/de/format.rs":"c85071b016df643b161859682d21ce34fa0ebf2a3bdbeeea69859da48f5d934f","src/de/ignored_any.rs":"6480f2b2a83dc4764d01b2eec7309729eef2492eede2e5ee98d23a60b05198eb","src/de/impls.rs":"cd2781405d8f4568701a701e6b9946e5956eb201571118c8a49038928477779a","src/de/mod.rs":"2be26b699feb8cc0c7f573d58fc11bb92d0b7bd1063bf8fcbd0e71d60f53c99a","src/de/seed.rs":"045d890712a04eb33ffc5a021e5d948a63c89402b8ffeea749df2171b7484f8f","src/de/size_hint.rs":"fff83dc39d30e75e8e611991f9c5399188a1aad23a6462dbca2c8b62655cfedb","src/de/value.rs":"0fd511a288c20a1b768718f4baadf9c7d4146d276af6a71ba1d0f7679b28644a","src/integer128.rs":"29ef30b7d94507b34807090e68173767cdc7aff62edccd38affe69e75338dddc","src/lib.rs":"0e4c06f18a0f2e46d60f54f463e906bf1ba1330ef9820a12173fd28a91b9fcde","src/macros.rs":"e3486ef4a9a4ed1b27234aa1817ccb25ec0eb026ffc95e2c71c7b917f1f45629","src/private/de.rs":"9255ecf2d5c52f0f52b4e0dbf85bdd8c140bc2c1ac96086ee395589e0521aeb4","src/private/doc.rs":"b222decb40321190155209e1b8a5a52e3adfaa470047e379e664b71e0320655a","src/private/mod.rs":"b8f0c348621d91dd9da3db83d8877e70bc61ad0a2dc2d6fb57c6fc2c2cbafa26","src/private/ser.rs":"73577607e779e1b42713c51b9bc7136f99daccf473b4a641c99ceebe46708d47","src/ser/fmt.rs":"d1cfd9623605413e45a23ef778d97f0ac4da4adaed23739f1f9d7414b30e384b","src/ser/impls.rs":"0eebc159f7d3962c46c323e456afb679747ff57563e796c5fd92c64ed074ae70","src/ser/impossible.rs":"5c325da8e0370ab22abe1e15d8af1dc7a1707b127508f61e720cd7f0caa80593","src/ser/mod.rs":"a92d4ce0a6c68eb22a24a61574a5d2e9b0b463b284ff08e62298b8f7ae1a7464","src/std_error.rs":"25a07149e2e468747ffa5a58051c7f93d7b3c0fa0372f012a96c97ec8ab03b97"},"package":"9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"} \ No newline at end of file
diff --git a/third_party/rust/serde/Cargo.toml b/third_party/rust/serde/Cargo.toml
index 6ba68688ac..b6f335bafd 100644
--- a/third_party/rust/serde/Cargo.toml
+++ b/third_party/rust/serde/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.31"
name = "serde"
-version = "1.0.197"
+version = "1.0.198"
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
"David Tolnay <dtolnay@gmail.com>",
@@ -74,4 +74,4 @@ std = []
unstable = []
[target."cfg(any())".dependencies.serde_derive]
-version = "=1.0.197"
+version = "=1.0.198"
diff --git a/third_party/rust/serde/build.rs b/third_party/rust/serde/build.rs
index fe5486a7a5..0074df63f4 100644
--- a/third_party/rust/serde/build.rs
+++ b/third_party/rust/serde/build.rs
@@ -64,6 +64,12 @@ fn main() {
if minor < 64 {
println!("cargo:rustc-cfg=no_core_cstr");
}
+
+ // Support for core::num::Saturating and std::num::Saturating stabilized in Rust 1.74
+ // https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html#stabilized-apis
+ if minor < 74 {
+ println!("cargo:rustc-cfg=no_core_num_saturating");
+ }
}
fn rustc_minor_version() -> Option<u32> {
diff --git a/third_party/rust/serde/src/de/impls.rs b/third_party/rust/serde/src/de/impls.rs
index 413c997afd..140878aec6 100644
--- a/third_party/rust/serde/src/de/impls.rs
+++ b/third_party/rust/serde/src/de/impls.rs
@@ -104,6 +104,28 @@ macro_rules! impl_deserialize_num {
deserializer.$deserialize(NonZeroVisitor)
}
}
+
+ #[cfg(not(no_core_num_saturating))]
+ impl<'de> Deserialize<'de> for Saturating<$primitive> {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ struct SaturatingVisitor;
+
+ impl<'de> Visitor<'de> for SaturatingVisitor {
+ type Value = Saturating<$primitive>;
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ formatter.write_str("integer with support for saturating semantics")
+ }
+
+ $($($method!(saturating $primitive $val : $visit);)*)*
+ }
+
+ deserializer.$deserialize(SaturatingVisitor)
+ }
+ }
};
($primitive:ident, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
@@ -154,6 +176,15 @@ macro_rules! num_self {
}
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ Ok(Saturating(v))
+ }
+ };
}
macro_rules! num_as_self {
@@ -179,6 +210,15 @@ macro_rules! num_as_self {
}
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ Ok(Saturating(v as $primitive))
+ }
+ };
}
macro_rules! num_as_copysign_self {
@@ -235,6 +275,21 @@ macro_rules! int_to_int {
Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if (v as i64) < $primitive::MIN as i64 {
+ Ok(Saturating($primitive::MIN))
+ } else if ($primitive::MAX as i64) < v as i64 {
+ Ok(Saturating($primitive::MAX))
+ } else {
+ Ok(Saturating(v as $primitive))
+ }
+ }
+ };
}
macro_rules! int_to_uint {
@@ -265,6 +320,21 @@ macro_rules! int_to_uint {
Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v < 0 {
+ Ok(Saturating(0))
+ } else if ($primitive::MAX as u64) < v as u64 {
+ Ok(Saturating($primitive::MAX))
+ } else {
+ Ok(Saturating(v as $primitive))
+ }
+ }
+ };
}
macro_rules! uint_to_self {
@@ -295,6 +365,19 @@ macro_rules! uint_to_self {
Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self))
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v as u64 <= $primitive::MAX as u64 {
+ Ok(Saturating(v as $primitive))
+ } else {
+ Ok(Saturating($primitive::MAX))
+ }
+ }
+ };
}
impl_deserialize_num! {
@@ -427,6 +510,21 @@ macro_rules! num_128 {
}
}
};
+
+ (saturating $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if (v as i128) < $primitive::MIN as i128 {
+ Ok(Saturating($primitive::MIN))
+ } else if ($primitive::MAX as u128) < v as u128 {
+ Ok(Saturating($primitive::MAX))
+ } else {
+ Ok(Saturating(v as $primitive))
+ }
+ }
+ };
}
impl_deserialize_num! {
@@ -852,7 +950,10 @@ struct PhantomDataVisitor<T: ?Sized> {
marker: PhantomData<T>,
}
-impl<'de, T: ?Sized> Visitor<'de> for PhantomDataVisitor<T> {
+impl<'de, T> Visitor<'de> for PhantomDataVisitor<T>
+where
+ T: ?Sized,
+{
type Value = PhantomData<T>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@@ -868,7 +969,10 @@ impl<'de, T: ?Sized> Visitor<'de> for PhantomDataVisitor<T> {
}
}
-impl<'de, T: ?Sized> Deserialize<'de> for PhantomData<T> {
+impl<'de, T> Deserialize<'de> for PhantomData<T>
+where
+ T: ?Sized,
+{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
@@ -1877,9 +1981,9 @@ forwarded_impl! {
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
-impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T>
+impl<'de, 'a, T> Deserialize<'de> for Cow<'a, T>
where
- T: ToOwned,
+ T: ?Sized + ToOwned,
T::Owned: Deserialize<'de>,
{
#[inline]
@@ -1902,7 +2006,7 @@ where
doc_cfg,
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
)]
-impl<'de, T: ?Sized> Deserialize<'de> for RcWeak<T>
+impl<'de, T> Deserialize<'de> for RcWeak<T>
where
T: Deserialize<'de>,
{
@@ -1924,7 +2028,7 @@ where
doc_cfg,
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
)]
-impl<'de, T: ?Sized> Deserialize<'de> for ArcWeak<T>
+impl<'de, T> Deserialize<'de> for ArcWeak<T>
where
T: Deserialize<'de>,
{
@@ -1945,8 +2049,9 @@ macro_rules! box_forwarded_impl {
$t:ident
) => {
$(#[$attr])*
- impl<'de, T: ?Sized> Deserialize<'de> for $t<T>
+ impl<'de, T> Deserialize<'de> for $t<T>
where
+ T: ?Sized,
Box<T>: Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
diff --git a/third_party/rust/serde/src/de/mod.rs b/third_party/rust/serde/src/de/mod.rs
index 1924fe3d88..4c5a5f9b78 100644
--- a/third_party/rust/serde/src/de/mod.rs
+++ b/third_party/rust/serde/src/de/mod.rs
@@ -1735,9 +1735,9 @@ pub trait SeqAccess<'de> {
}
}
-impl<'de, 'a, A: ?Sized> SeqAccess<'de> for &'a mut A
+impl<'de, 'a, A> SeqAccess<'de> for &'a mut A
where
- A: SeqAccess<'de>,
+ A: ?Sized + SeqAccess<'de>,
{
type Error = A::Error;
@@ -1888,9 +1888,9 @@ pub trait MapAccess<'de> {
}
}
-impl<'de, 'a, A: ?Sized> MapAccess<'de> for &'a mut A
+impl<'de, 'a, A> MapAccess<'de> for &'a mut A
where
- A: MapAccess<'de>,
+ A: ?Sized + MapAccess<'de>,
{
type Error = A::Error;
diff --git a/third_party/rust/serde/src/lib.rs b/third_party/rust/serde/src/lib.rs
index 5cf44c1c18..fefbf8fda2 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.197")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.198")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Show which crate feature enables conditionally compiled APIs in documentation.
@@ -274,6 +274,9 @@ mod lib {
pub use std::sync::atomic::{AtomicI64, AtomicU64};
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))]
pub use std::sync::atomic::{AtomicIsize, AtomicUsize};
+
+ #[cfg(not(no_core_num_saturating))]
+ pub use self::core::num::Saturating;
}
// None of this crate's error handling needs the `From::from` error conversion
diff --git a/third_party/rust/serde/src/private/de.rs b/third_party/rust/serde/src/private/de.rs
index 883e6909c1..c402d2c66a 100644
--- a/third_party/rust/serde/src/private/de.rs
+++ b/third_party/rust/serde/src/private/de.rs
@@ -313,6 +313,8 @@ mod content {
}
}
+ /// Used to capture data in [`Content`] from other deserializers.
+ /// Cannot capture externally tagged enums, `i128` and `u128`.
struct ContentVisitor<'de> {
value: PhantomData<Content<'de>>,
}
@@ -528,6 +530,8 @@ mod content {
Content(Content<'de>),
}
+ /// Serves as a seed for deserializing a key of internally tagged enum.
+ /// Cannot capture externally tagged enums, `i128` and `u128`.
struct TagOrContentVisitor<'de> {
name: &'static str,
value: PhantomData<TagOrContent<'de>>,
@@ -814,6 +818,9 @@ mod content {
/// Used by generated code to deserialize an internally tagged enum.
///
+ /// Captures map or sequence from the original deserializer and searches
+ /// a tag in it (in case of sequence, tag is the first element of sequence).
+ ///
/// Not public API.
pub struct TaggedContentVisitor<T> {
tag_name: &'static str,
diff --git a/third_party/rust/serde/src/private/doc.rs b/third_party/rust/serde/src/private/doc.rs
index 1b18fe6b41..1f17c8db53 100644
--- a/third_party/rust/serde/src/private/doc.rs
+++ b/third_party/rust/serde/src/private/doc.rs
@@ -56,7 +56,10 @@ macro_rules! __serialize_unimplemented {
#[macro_export]
macro_rules! __serialize_unimplemented_method {
($func:ident $(<$t:ident>)* ($($arg:ty),*) -> $ret:ident) => {
- fn $func $(<$t: ?Sized + $crate::Serialize>)* (self $(, _: $arg)*) -> $crate::__private::Result<Self::$ret, Self::Error> {
+ fn $func $(<$t>)* (self $(, _: $arg)*) -> $crate::__private::Result<Self::$ret, Self::Error>
+ where
+ $($t: ?Sized + $crate::Serialize,)*
+ {
unimplemented!()
}
};
diff --git a/third_party/rust/serde/src/private/ser.rs b/third_party/rust/serde/src/private/ser.rs
index 50bcb251e3..40cc6cbdb7 100644
--- a/third_party/rust/serde/src/private/ser.rs
+++ b/third_party/rust/serde/src/private/ser.rs
@@ -174,9 +174,9 @@ where
Err(self.bad_type(Unsupported::Optional))
}
- fn serialize_some<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
+ fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Err(self.bad_type(Unsupported::Optional))
}
@@ -205,18 +205,18 @@ where
map.end()
}
- fn serialize_newtype_struct<T: ?Sized>(
+ fn serialize_newtype_struct<T>(
self,
_: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
value.serialize(self)
}
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
_: &'static str,
_: u32,
@@ -224,7 +224,7 @@ where
inner_value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let mut map = tri!(self.delegate.serialize_map(Some(2)));
tri!(map.serialize_entry(self.tag, self.variant_name));
@@ -327,9 +327,9 @@ where
}
#[cfg(not(any(feature = "std", feature = "alloc")))]
- fn collect_str<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
+ fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
where
- T: Display,
+ T: ?Sized + Display,
{
Err(self.bad_type(Unsupported::String))
}
@@ -364,9 +364,9 @@ mod content {
type Ok = M::Ok;
type Error = M::Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), M::Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), M::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push(value);
@@ -404,13 +404,9 @@ mod content {
type Ok = M::Ok;
type Error = M::Error;
- fn serialize_field<T: ?Sized>(
- &mut self,
- key: &'static str,
- value: &T,
- ) -> Result<(), M::Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), M::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
@@ -635,9 +631,9 @@ mod content {
Ok(Content::None)
}
- fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Content, E>
+ fn serialize_some<T>(self, value: &T) -> Result<Content, E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Ok(Content::Some(Box::new(tri!(value.serialize(self)))))
}
@@ -659,13 +655,9 @@ mod content {
Ok(Content::UnitVariant(name, variant_index, variant))
}
- fn serialize_newtype_struct<T: ?Sized>(
- self,
- name: &'static str,
- value: &T,
- ) -> Result<Content, E>
+ fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<Content, E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Ok(Content::NewtypeStruct(
name,
@@ -673,7 +665,7 @@ mod content {
))
}
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
@@ -681,7 +673,7 @@ mod content {
value: &T,
) -> Result<Content, E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Ok(Content::NewtypeVariant(
name,
@@ -782,9 +774,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
@@ -808,9 +800,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
@@ -835,9 +827,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
@@ -864,9 +856,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
@@ -896,18 +888,18 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), E>
+ fn serialize_key<T>(&mut self, key: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let key = tri!(key.serialize(ContentSerializer::<E>::new()));
self.key = Some(key);
Ok(())
}
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
+ fn serialize_value<T>(&mut self, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let key = self
.key
@@ -922,10 +914,10 @@ mod content {
Ok(Content::Map(self.entries))
}
- fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<(), E>
+ fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), E>
where
- K: Serialize,
- V: Serialize,
+ K: ?Sized + Serialize,
+ V: ?Sized + Serialize,
{
let key = tri!(key.serialize(ContentSerializer::<E>::new()));
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
@@ -947,9 +939,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
@@ -976,9 +968,9 @@ mod content {
type Ok = Content;
type Error = E;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
@@ -1088,9 +1080,9 @@ where
Ok(())
}
- fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
+ fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
value.serialize(self)
}
@@ -1112,18 +1104,18 @@ where
Err(Self::bad_type(Unsupported::Enum))
}
- fn serialize_newtype_struct<T: ?Sized>(
+ fn serialize_newtype_struct<T>(
self,
_: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
value.serialize(self)
}
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
_: &'static str,
_: u32,
@@ -1131,7 +1123,7 @@ where
value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
tri!(self.0.serialize_key(variant));
self.0.serialize_value(value)
@@ -1202,28 +1194,24 @@ where
type Ok = ();
type Error = M::Error;
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
+ fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
self.0.serialize_key(key)
}
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
self.0.serialize_value(value)
}
- fn serialize_entry<K: ?Sized, V: ?Sized>(
- &mut self,
- key: &K,
- value: &V,
- ) -> Result<(), Self::Error>
+ fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error>
where
- K: Serialize,
- V: Serialize,
+ K: ?Sized + Serialize,
+ V: ?Sized + Serialize,
{
self.0.serialize_entry(key, value)
}
@@ -1244,13 +1232,9 @@ where
type Ok = ();
type Error = M::Error;
- fn serialize_field<T: ?Sized>(
- &mut self,
- key: &'static str,
- value: &T,
- ) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
self.0.serialize_entry(key, value)
}
@@ -1289,9 +1273,9 @@ where
type Ok = ();
type Error = M::Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push(value);
@@ -1335,13 +1319,9 @@ where
type Ok = ();
type Error = M::Error;
- fn serialize_field<T: ?Sized>(
- &mut self,
- key: &'static str,
- value: &T,
- ) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
diff --git a/third_party/rust/serde/src/ser/fmt.rs b/third_party/rust/serde/src/ser/fmt.rs
index 0650ab6f12..04684aded0 100644
--- a/third_party/rust/serde/src/ser/fmt.rs
+++ b/third_party/rust/serde/src/ser/fmt.rs
@@ -74,9 +74,9 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
Display::fmt(variant, self)
}
- fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> fmt::Result
+ fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> fmt::Result
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Serialize::serialize(value, self)
}
@@ -89,9 +89,9 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
Err(fmt::Error)
}
- fn serialize_some<T: ?Sized>(self, _value: &T) -> fmt::Result
+ fn serialize_some<T>(self, _value: &T) -> fmt::Result
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Err(fmt::Error)
}
@@ -100,7 +100,7 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
Err(fmt::Error)
}
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
@@ -108,7 +108,7 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
_value: &T,
) -> fmt::Result
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
Err(fmt::Error)
}
@@ -161,9 +161,9 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
Err(fmt::Error)
}
- fn collect_str<T: ?Sized>(self, value: &T) -> fmt::Result
+ fn collect_str<T>(self, value: &T) -> fmt::Result
where
- T: Display,
+ T: ?Sized + Display,
{
Display::fmt(value, self)
}
diff --git a/third_party/rust/serde/src/ser/impls.rs b/third_party/rust/serde/src/ser/impls.rs
index 8c70634af0..ffc4c70f90 100644
--- a/third_party/rust/serde/src/ser/impls.rs
+++ b/third_party/rust/serde/src/ser/impls.rs
@@ -114,7 +114,10 @@ where
////////////////////////////////////////////////////////////////////////////////
-impl<T: ?Sized> Serialize for PhantomData<T> {
+impl<T> Serialize for PhantomData<T>
+where
+ T: ?Sized,
+{
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -504,17 +507,17 @@ macro_rules! deref_impl {
}
deref_impl! {
- <'a, T: ?Sized> Serialize for &'a T where T: Serialize
+ <'a, T> Serialize for &'a T where T: ?Sized + Serialize
}
deref_impl! {
- <'a, T: ?Sized> Serialize for &'a mut T where T: Serialize
+ <'a, T> Serialize for &'a mut T where T: ?Sized + Serialize
}
deref_impl! {
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
- <T: ?Sized> Serialize for Box<T> where T: Serialize
+ <T> Serialize for Box<T> where T: ?Sized + Serialize
}
deref_impl! {
@@ -528,7 +531,7 @@ deref_impl! {
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
- <T: ?Sized> Serialize for Rc<T> where T: Serialize
+ <T> Serialize for Rc<T> where T: ?Sized + Serialize
}
deref_impl! {
@@ -542,13 +545,13 @@ deref_impl! {
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
- <T: ?Sized> Serialize for Arc<T> where T: Serialize
+ <T> Serialize for Arc<T> where T: ?Sized + Serialize
}
deref_impl! {
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
- <'a, T: ?Sized> Serialize for Cow<'a, T> where T: Serialize + ToOwned
+ <'a, T> Serialize for Cow<'a, T> where T: ?Sized + Serialize + ToOwned
}
////////////////////////////////////////////////////////////////////////////////
@@ -561,9 +564,9 @@ deref_impl! {
doc_cfg,
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
)]
-impl<T: ?Sized> Serialize for RcWeak<T>
+impl<T> Serialize for RcWeak<T>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -581,9 +584,9 @@ where
doc_cfg,
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
)]
-impl<T: ?Sized> Serialize for ArcWeak<T>
+impl<T> Serialize for ArcWeak<T>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -641,9 +644,9 @@ where
}
}
-impl<T: ?Sized> Serialize for RefCell<T>
+impl<T> Serialize for RefCell<T>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -658,9 +661,9 @@ where
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
-impl<T: ?Sized> Serialize for Mutex<T>
+impl<T> Serialize for Mutex<T>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -675,9 +678,9 @@ where
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
-impl<T: ?Sized> Serialize for RwLock<T>
+impl<T> Serialize for RwLock<T>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -1023,6 +1026,20 @@ where
}
}
+#[cfg(not(no_core_num_saturating))]
+impl<T> Serialize for Saturating<T>
+where
+ T: Serialize,
+{
+ #[inline]
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ self.0.serialize(serializer)
+ }
+}
+
impl<T> Serialize for Reverse<T>
where
T: Serialize,
diff --git a/third_party/rust/serde/src/ser/impossible.rs b/third_party/rust/serde/src/ser/impossible.rs
index 479be94071..6432d5775a 100644
--- a/third_party/rust/serde/src/ser/impossible.rs
+++ b/third_party/rust/serde/src/ser/impossible.rs
@@ -72,9 +72,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = value;
match self.void {}
@@ -92,9 +92,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = value;
match self.void {}
@@ -112,9 +112,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = value;
match self.void {}
@@ -132,9 +132,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = value;
match self.void {}
@@ -152,17 +152,17 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Error>
+ fn serialize_key<T>(&mut self, key: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = key;
match self.void {}
}
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
+ fn serialize_value<T>(&mut self, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = value;
match self.void {}
@@ -180,9 +180,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = key;
let _ = value;
@@ -201,9 +201,9 @@ where
type Ok = Ok;
type Error = Error;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let _ = key;
let _ = value;
diff --git a/third_party/rust/serde/src/ser/mod.rs b/third_party/rust/serde/src/ser/mod.rs
index 75c45140e2..74b5e07691 100644
--- a/third_party/rust/serde/src/ser/mod.rs
+++ b/third_party/rust/serde/src/ser/mod.rs
@@ -796,9 +796,9 @@ pub trait Serializer: Sized {
/// ```
///
/// [`Some(T)`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some
- fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
+ fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Serialize a `()` value.
///
@@ -891,13 +891,13 @@ pub trait Serializer: Sized {
/// }
/// }
/// ```
- fn serialize_newtype_struct<T: ?Sized>(
+ fn serialize_newtype_struct<T>(
self,
name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Serialize a newtype variant like `E::N` in `enum E { N(u8) }`.
///
@@ -925,7 +925,7 @@ pub trait Serializer: Sized {
/// }
/// }
/// ```
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
@@ -933,7 +933,7 @@ pub trait Serializer: Sized {
value: &T,
) -> Result<Self::Ok, Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Begin to serialize a variably sized sequence. This call must be
/// followed by zero or more calls to `serialize_element`, then a call to
@@ -1170,7 +1170,8 @@ pub trait Serializer: Sized {
/// then a call to `end`.
///
/// The `name` is the name of the struct and the `len` is the number of
- /// data fields that will be serialized.
+ /// data fields that will be serialized. `len` does not include fields
+ /// which are skipped with [`SerializeStruct::skip_field`].
///
/// ```edition2021
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
@@ -1207,6 +1208,8 @@ pub trait Serializer: Sized {
/// The `name` is the name of the enum, the `variant_index` is the index of
/// this variant within the enum, the `variant` is the name of the variant,
/// and the `len` is the number of data fields that will be serialized.
+ /// `len` does not include fields which are skipped with
+ /// [`SerializeStructVariant::skip_field`].
///
/// ```edition2021
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
@@ -1346,9 +1349,9 @@ pub trait Serializer: Sized {
/// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html
/// [`serialize_str`]: #tymethod.serialize_str
#[cfg(any(feature = "std", feature = "alloc"))]
- fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
+ fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
- T: Display,
+ T: ?Sized + Display,
{
self.serialize_str(&value.to_string())
}
@@ -1379,9 +1382,9 @@ pub trait Serializer: Sized {
/// }
/// ```
#[cfg(not(any(feature = "std", feature = "alloc")))]
- fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
+ fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
- T: Display;
+ T: ?Sized + Display;
/// Determine whether `Serialize` implementations should serialize in
/// human-readable form.
@@ -1493,9 +1496,9 @@ pub trait SerializeSeq {
type Error: Error;
/// Serialize a sequence element.
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Finish serializing a sequence.
fn end(self) -> Result<Self::Ok, Self::Error>;
@@ -1593,9 +1596,9 @@ pub trait SerializeTuple {
type Error: Error;
/// Serialize a tuple element.
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Finish serializing a tuple.
fn end(self) -> Result<Self::Ok, Self::Error>;
@@ -1638,9 +1641,9 @@ pub trait SerializeTupleStruct {
type Error: Error;
/// Serialize a tuple struct field.
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Finish serializing a tuple struct.
fn end(self) -> Result<Self::Ok, Self::Error>;
@@ -1696,9 +1699,9 @@ pub trait SerializeTupleVariant {
type Error: Error;
/// Serialize a tuple variant field.
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Finish serializing a tuple variant.
fn end(self) -> Result<Self::Ok, Self::Error>;
@@ -1767,9 +1770,9 @@ pub trait SerializeMap {
/// `serialize_entry` instead as it may be implemented more efficiently in
/// some formats compared to a pair of calls to `serialize_key` and
/// `serialize_value`.
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
+ fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Serialize a map value.
///
@@ -1777,9 +1780,9 @@ pub trait SerializeMap {
///
/// Calling `serialize_value` before `serialize_key` is incorrect and is
/// allowed to panic or produce bogus results.
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Serialize a map entry consisting of a key and a value.
///
@@ -1798,14 +1801,10 @@ pub trait SerializeMap {
/// [`Serialize`]: ../trait.Serialize.html
/// [`serialize_key`]: #tymethod.serialize_key
/// [`serialize_value`]: #tymethod.serialize_value
- fn serialize_entry<K: ?Sized, V: ?Sized>(
- &mut self,
- key: &K,
- value: &V,
- ) -> Result<(), Self::Error>
+ fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error>
where
- K: Serialize,
- V: Serialize,
+ K: ?Sized + Serialize,
+ V: ?Sized + Serialize,
{
tri!(self.serialize_key(key));
self.serialize_value(value)
@@ -1856,15 +1855,13 @@ pub trait SerializeStruct {
type Error: Error;
/// Serialize a struct field.
- fn serialize_field<T: ?Sized>(
- &mut self,
- key: &'static str,
- value: &T,
- ) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Indicate that a struct field has been skipped.
+ ///
+ /// The default implementation does nothing.
#[inline]
fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
let _ = key;
@@ -1922,15 +1919,13 @@ pub trait SerializeStructVariant {
type Error: Error;
/// Serialize a struct variant field.
- fn serialize_field<T: ?Sized>(
- &mut self,
- key: &'static str,
- value: &T,
- ) -> Result<(), Self::Error>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
- T: Serialize;
+ T: ?Sized + Serialize;
/// Indicate that a struct variant field has been skipped.
+ ///
+ /// The default implementation does nothing.
#[inline]
fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
let _ = key;