Skip to main content

core/io/
impls.rs

1use crate::io::SizeHint;
2
3// =============================================================================
4// Forwarding implementations
5
6#[doc(hidden)]
7#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
8impl<T> SizeHint for &mut T {
9    #[inline]
10    fn lower_bound(&self) -> usize {
11        SizeHint::lower_bound(*self)
12    }
13
14    #[inline]
15    fn upper_bound(&self) -> Option<usize> {
16        SizeHint::upper_bound(*self)
17    }
18}
19
20// =============================================================================
21// In-memory buffer implementations
22
23#[doc(hidden)]
24#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
25impl SizeHint for &[u8] {
26    #[inline]
27    fn lower_bound(&self) -> usize {
28        self.len()
29    }
30
31    #[inline]
32    fn upper_bound(&self) -> Option<usize> {
33        Some(self.len())
34    }
35}