mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-23 02:31:04 +00:00
Move size_hint module out of private::de
This commit is contained in:
@@ -10,7 +10,7 @@ use de::MapAccess;
|
|||||||
use seed::InPlaceSeed;
|
use seed::InPlaceSeed;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use __private::de::size_hint;
|
use __private::size_hint;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
use self::private::{First, Second};
|
use self::private::{First, Second};
|
||||||
use __private::de::size_hint;
|
use __private::size_hint;
|
||||||
use de::{self, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
|
use de::{self, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
|
||||||
use ser;
|
use ser;
|
||||||
|
|
||||||
|
|||||||
+1
-24
@@ -191,29 +191,6 @@ where
|
|||||||
.map(From::from)
|
.map(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod size_hint {
|
|
||||||
use lib::*;
|
|
||||||
|
|
||||||
pub fn from_bounds<I>(iter: &I) -> Option<usize>
|
|
||||||
where
|
|
||||||
I: Iterator,
|
|
||||||
{
|
|
||||||
helper(iter.size_hint())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn cautious(hint: Option<usize>) -> usize {
|
|
||||||
cmp::min(hint.unwrap_or(0), 4096)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn helper(bounds: (usize, Option<usize>)) -> Option<usize> {
|
|
||||||
match bounds {
|
|
||||||
(lower, Some(upper)) if lower == upper => Some(upper),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
mod content {
|
mod content {
|
||||||
// This module is private and nothing here should be used outside of
|
// This module is private and nothing here should be used outside of
|
||||||
@@ -228,7 +205,7 @@ mod content {
|
|||||||
|
|
||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
use super::size_hint;
|
use __private::size_hint;
|
||||||
use de::{
|
use de::{
|
||||||
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
||||||
MapAccess, SeqAccess, Unexpected, Visitor,
|
MapAccess, SeqAccess, Unexpected, Visitor,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod de;
|
pub mod de;
|
||||||
pub mod ser;
|
pub mod ser;
|
||||||
|
pub mod size_hint;
|
||||||
|
|
||||||
// FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.
|
// FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.
|
||||||
pub mod doc;
|
pub mod doc;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
use lib::*;
|
||||||
|
|
||||||
|
pub fn from_bounds<I>(iter: &I) -> Option<usize>
|
||||||
|
where
|
||||||
|
I: Iterator,
|
||||||
|
{
|
||||||
|
helper(iter.size_hint())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn cautious(hint: Option<usize>) -> usize {
|
||||||
|
cmp::min(hint.unwrap_or(0), 4096)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn helper(bounds: (usize, Option<usize>)) -> Option<usize> {
|
||||||
|
match bounds {
|
||||||
|
(lower, Some(upper)) if lower == upper => Some(upper),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user