Sha256: fff83dc39d30e75e8e611991f9c5399188a1aad23a6462dbca2c8b62655cfedb
Contents?: true
Size: 644 Bytes
Versions: 30
Compression:
Stored size: 644 Bytes
Contents
use crate::lib::*; pub fn from_bounds<I>(iter: &I) -> Option<usize> where I: Iterator, { helper(iter.size_hint()) } #[cfg(any(feature = "std", feature = "alloc"))] pub fn cautious<Element>(hint: Option<usize>) -> usize { const MAX_PREALLOC_BYTES: usize = 1024 * 1024; if mem::size_of::<Element>() == 0 { 0 } else { cmp::min( hint.unwrap_or(0), MAX_PREALLOC_BYTES / mem::size_of::<Element>(), ) } } fn helper(bounds: (usize, Option<usize>)) -> Option<usize> { match bounds { (lower, Some(upper)) if lower == upper => Some(upper), _ => None, } }
Version data entries
30 entries across 30 versions & 1 rubygems