mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-20 13:51:05 +00:00
Move InPlaceSeed out of private mod
This commit is contained in:
@@ -7,7 +7,7 @@ use de::{
|
|||||||
#[cfg(any(core_duration, feature = "std", feature = "alloc"))]
|
#[cfg(any(core_duration, feature = "std", feature = "alloc"))]
|
||||||
use de::MapAccess;
|
use de::MapAccess;
|
||||||
|
|
||||||
use __private::de::InPlaceSeed;
|
use seed::InPlaceSeed;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use __private::de::size_hint;
|
use __private::de::size_hint;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
use de::{Deserialize, DeserializeSeed, Deserializer};
|
||||||
|
|
||||||
|
/// A DeserializeSeed helper for implementing deserialize_in_place Visitors.
|
||||||
|
///
|
||||||
|
/// Wraps a mutable reference and calls deserialize_in_place on it.
|
||||||
|
pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);
|
||||||
|
|
||||||
|
impl<'a, 'de, T> DeserializeSeed<'de> for InPlaceSeed<'a, T>
|
||||||
|
where
|
||||||
|
T: Deserialize<'de>,
|
||||||
|
{
|
||||||
|
type Value = ();
|
||||||
|
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
T::deserialize_in_place(deserializer, self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -276,6 +276,9 @@ use self::__private as export;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use self::__private as private;
|
use self::__private as private;
|
||||||
|
|
||||||
|
#[path = "de/seed.rs"]
|
||||||
|
mod seed;
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
mod std_error;
|
mod std_error;
|
||||||
|
|
||||||
|
|||||||
+4
-20
@@ -1,10 +1,10 @@
|
|||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
use de::value::{BorrowedBytesDeserializer, BytesDeserializer};
|
use de::value::{BorrowedBytesDeserializer, BytesDeserializer};
|
||||||
use de::{Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, Visitor};
|
use de::{Deserialize, Deserializer, Error, IntoDeserializer, Visitor};
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use de::{MapAccess, Unexpected};
|
use de::{DeserializeSeed, MapAccess, Unexpected};
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub use self::content::{
|
pub use self::content::{
|
||||||
@@ -13,6 +13,8 @@ pub use self::content::{
|
|||||||
TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor, UntaggedUnitVisitor,
|
TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor, UntaggedUnitVisitor,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub use seed::InPlaceSeed;
|
||||||
|
|
||||||
/// If the missing field is of type `Option<T>` then treat is as `None`,
|
/// If the missing field is of type `Option<T>` then treat is as `None`,
|
||||||
/// otherwise it is an error.
|
/// otherwise it is an error.
|
||||||
pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E>
|
pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E>
|
||||||
@@ -2666,24 +2668,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A DeserializeSeed helper for implementing deserialize_in_place Visitors.
|
|
||||||
///
|
|
||||||
/// Wraps a mutable reference and calls deserialize_in_place on it.
|
|
||||||
pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);
|
|
||||||
|
|
||||||
impl<'a, 'de, T> DeserializeSeed<'de> for InPlaceSeed<'a, T>
|
|
||||||
where
|
|
||||||
T: Deserialize<'de>,
|
|
||||||
{
|
|
||||||
type Value = ();
|
|
||||||
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
T::deserialize_in_place(deserializer, self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub struct FlatMapDeserializer<'a, 'de: 'a, E>(
|
pub struct FlatMapDeserializer<'a, 'de: 'a, E>(
|
||||||
pub &'a mut Vec<Option<(Content<'de>, Content<'de>)>>,
|
pub &'a mut Vec<Option<(Content<'de>, Content<'de>)>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user