Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit ec88cd7

Browse files
committed
Remove seed module and functions
1 parent 33caf06 commit ec88cd7

File tree

3 files changed

+5
-64
lines changed

3 files changed

+5
-64
lines changed

src/de.rs

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use serde::de::{
1010
};
1111
use std::fmt;
1212
use std::io;
13-
use std::marker::PhantomData;
1413
use std::mem;
1514
use std::num::ParseIntError;
1615
use std::str;
@@ -1760,23 +1759,7 @@ pub fn from_str<'de, T>(s: &'de str) -> Result<T>
17601759
where
17611760
T: Deserialize<'de>,
17621761
{
1763-
from_str_seed(s, PhantomData)
1764-
}
1765-
1766-
/// Deserialize an instance of type `T` from a string of YAML text with a seed.
1767-
///
1768-
/// This conversion can fail if the structure of the Value does not match the
1769-
/// structure expected by `T`, for example if `T` is a struct type but the Value
1770-
/// contains something other than a YAML map. It can also fail if the structure
1771-
/// is correct but `T`'s implementation of `Deserialize` decides that something
1772-
/// is wrong with the data, for example required struct fields are missing from
1773-
/// the YAML map or some number is too big to fit in the expected primitive
1774-
/// type.
1775-
pub fn from_str_seed<'de, T, S>(s: &'de str, seed: S) -> Result<T>
1776-
where
1777-
S: DeserializeSeed<'de, Value = T>,
1778-
{
1779-
seed.deserialize(Deserializer::from_str(s))
1762+
T::deserialize(Deserializer::from_str(s))
17801763
}
17811764

17821765
/// Deserialize an instance of type `T` from an IO stream of YAML.
@@ -1793,24 +1776,7 @@ where
17931776
R: io::Read,
17941777
T: DeserializeOwned,
17951778
{
1796-
from_reader_seed(rdr, PhantomData)
1797-
}
1798-
1799-
/// Deserialize an instance of type `T` from an IO stream of YAML with a seed.
1800-
///
1801-
/// This conversion can fail if the structure of the Value does not match the
1802-
/// structure expected by `T`, for example if `T` is a struct type but the Value
1803-
/// contains something other than a YAML map. It can also fail if the structure
1804-
/// is correct but `T`'s implementation of `Deserialize` decides that something
1805-
/// is wrong with the data, for example required struct fields are missing from
1806-
/// the YAML map or some number is too big to fit in the expected primitive
1807-
/// type.
1808-
pub fn from_reader_seed<R, T, S>(rdr: R, seed: S) -> Result<T>
1809-
where
1810-
R: io::Read,
1811-
S: for<'de> DeserializeSeed<'de, Value = T>,
1812-
{
1813-
seed.deserialize(Deserializer::from_reader(rdr))
1779+
T::deserialize(Deserializer::from_reader(rdr))
18141780
}
18151781

18161782
/// Deserialize an instance of type `T` from bytes of YAML text.
@@ -1826,21 +1792,5 @@ pub fn from_slice<'de, T>(v: &'de [u8]) -> Result<T>
18261792
where
18271793
T: Deserialize<'de>,
18281794
{
1829-
from_slice_seed(v, PhantomData)
1830-
}
1831-
1832-
/// Deserialize an instance of type `T` from bytes of YAML text with a seed.
1833-
///
1834-
/// This conversion can fail if the structure of the Value does not match the
1835-
/// structure expected by `T`, for example if `T` is a struct type but the Value
1836-
/// contains something other than a YAML map. It can also fail if the structure
1837-
/// is correct but `T`'s implementation of `Deserialize` decides that something
1838-
/// is wrong with the data, for example required struct fields are missing from
1839-
/// the YAML map or some number is too big to fit in the expected primitive
1840-
/// type.
1841-
pub fn from_slice_seed<'de, T, S>(v: &'de [u8], seed: S) -> Result<T>
1842-
where
1843-
S: DeserializeSeed<'de, Value = T>,
1844-
{
1845-
seed.deserialize(Deserializer::from_slice(v))
1795+
T::deserialize(Deserializer::from_slice(v))
18461796
}

src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,6 @@ pub use crate::value::{from_value, to_value, Index, Number, Sequence, Value};
168168
#[doc(inline)]
169169
pub use crate::mapping::Mapping;
170170

171-
/// Entry points for deserializing with pre-existing state.
172-
///
173-
/// These functions are only exposed this way because we don't yet expose a
174-
/// Deserializer type. Data formats that have a public Deserializer should not
175-
/// copy these signatures.
176-
pub mod seed {
177-
pub use super::de::{from_reader_seed, from_slice_seed, from_str_seed};
178-
}
179-
180171
mod de;
181172
mod error;
182173
mod libyaml;

tests/test_de.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use indoc::indoc;
88
use serde_derive::Deserialize;
9-
use serde_yaml::Value;
9+
use serde_yaml::{Deserializer, Value};
1010
use std::collections::BTreeMap;
1111
use std::fmt::Debug;
1212

@@ -43,7 +43,7 @@ where
4343
T: PartialEq + Debug,
4444
S: serde::de::DeserializeSeed<'de, Value = T>,
4545
{
46-
let deserialized: T = serde_yaml::seed::from_str_seed(yaml, seed).unwrap();
46+
let deserialized: T = seed.deserialize(Deserializer::from_str(yaml)).unwrap();
4747
assert_eq!(*expected, deserialized);
4848

4949
serde_yaml::from_str::<serde_yaml::Value>(yaml).unwrap();

0 commit comments

Comments
 (0)