Make size_hint private

This commit is contained in:
David Tolnay
2025-09-13 12:12:05 -07:00
parent 7f831225a9
commit f916ec6baa
7 changed files with 11 additions and 12 deletions
+3 -3
View File
@@ -209,11 +209,11 @@ mod content {
use crate::lib::*; use crate::lib::*;
use crate::de::{ use crate::de::{
self, size_hint, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
IgnoredAny, MapAccess, SeqAccess, Unexpected, Visitor, MapAccess, SeqAccess, Unexpected, Visitor,
}; };
pub use serde_core::__private::Content; pub use serde_core::__private::Content;
use serde_core::__private::ContentVisitor; use serde_core::__private::{size_hint, ContentVisitor};
pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a str> { pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a str> {
match *content { match *content {
+1 -1
View File
@@ -8,7 +8,7 @@ use crate::private;
use crate::seed::InPlaceSeed; use crate::seed::InPlaceSeed;
#[cfg(any(feature = "std", feature = "alloc"))] #[cfg(any(feature = "std", feature = "alloc"))]
use crate::de::size_hint; use crate::private::size_hint;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
-1
View File
@@ -120,7 +120,6 @@ pub mod value;
mod ignored_any; mod ignored_any;
mod impls; mod impls;
pub mod size_hint;
pub use self::ignored_any::IgnoredAny; pub use self::ignored_any::IgnoredAny;
pub use crate::seed::InPlaceSeed; pub use crate::seed::InPlaceSeed;
+2 -1
View File
@@ -24,7 +24,8 @@
use crate::lib::*; use crate::lib::*;
use self::private::{First, Second}; use self::private::{First, Second};
use crate::de::{self, size_hint, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor}; use crate::de::{self, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
use crate::private::size_hint;
use crate::ser; use crate::ser;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
+2 -3
View File
@@ -1,7 +1,6 @@
use crate::de::{ use crate::de::{self, Deserialize, Deserializer, EnumAccess, MapAccess, SeqAccess, Visitor};
self, size_hint, Deserialize, Deserializer, EnumAccess, MapAccess, SeqAccess, Visitor,
};
use crate::lib::*; use crate::lib::*;
use crate::private::size_hint;
// Used from generated code to buffer the contents of the Deserializer when // Used from generated code to buffer the contents of the Deserializer when
// deserializing untagged enums and internally tagged enums. // deserializing untagged enums and internally tagged enums.
+3
View File
@@ -1,6 +1,9 @@
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))] #[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
mod content; mod content;
#[doc(hidden)]
pub mod size_hint;
#[doc(hidden)] #[doc(hidden)]
pub mod string; pub mod string;
@@ -1,8 +1,6 @@
//! Provides helpers for creating size hints for container deserialization.
#[cfg(any(feature = "std", feature = "alloc"))] #[cfg(any(feature = "std", feature = "alloc"))]
use crate::lib::*; use crate::lib::*;
/// Extracts the exact size of an iterator if it has a known upper bound and it matches the lower bound.
pub fn from_bounds<I>(iter: &I) -> Option<usize> pub fn from_bounds<I>(iter: &I) -> Option<usize>
where where
I: Iterator, I: Iterator,
@@ -10,7 +8,6 @@ where
helper(iter.size_hint()) helper(iter.size_hint())
} }
/// Returns conservative size estimate for a container, clamping the result to a maximum size.
#[cfg(any(feature = "std", feature = "alloc"))] #[cfg(any(feature = "std", feature = "alloc"))]
pub fn cautious<Element>(hint: Option<usize>) -> usize { pub fn cautious<Element>(hint: Option<usize>) -> usize {
const MAX_PREALLOC_BYTES: usize = 1024 * 1024; const MAX_PREALLOC_BYTES: usize = 1024 * 1024;