Struct LengthHint
struct LengthHint(251, 252)
A hint to help consumers of Writeable pre-allocate bytes before they call
write_to.
This behaves like Iterator::size_hint: it is a tuple where the first element is the
lower bound, and the second element is the upper bound. If the upper bound is None
either there is no known upper bound, or the upper bound is larger than usize.
LengthHint implements std::ops::{Add, Mul} and similar traits for easy composition.
During computation, the lower bound will saturate at usize::MAX, while the upper
bound will become None if usize::MAX is exceeded.
Implementations
impl LengthHint
fn undefined() -> Selffn exact(n: usize) -> Selfwrite_towill use exactly n bytes.fn at_least(n: usize) -> Selfwrite_towill use at least n bytes.fn at_most(n: usize) -> Selfwrite_towill use at most n bytes.fn between(n: usize, m: usize) -> Selfwrite_towill use betweennandmbytes.fn capacity(self: &Self) -> usizeReturns a recommendation for the number of bytes to pre-allocate. If an upper bound exists, this is used, otherwise the lower bound (which might be 0).
Examples
use Writeable;fn is_zero(self: &Self) -> boolReturns whether the
LengthHintindicates that the string is exactly 0 bytes long.
impl Add for LengthHint
fn add(self: Self, other: usize) -> Self
impl Add for LengthHint
fn add(self: Self, other: LengthHint) -> Self
impl AddAssign for LengthHint
fn add_assign(self: &mut Self, other: usize)
impl AddAssign for LengthHint
fn add_assign(self: &mut Self, other: Self)
impl BitOr for LengthHint
fn bitor(self: Self, other: LengthHint) -> SelfReturns a new hint that is correct wherever
selfis correct, and whereverotheris correct.Example:
# use ; # use fmt; # ; impl_display_with_writeable!;
impl BitOrAssign for LengthHint
fn bitor_assign(self: &mut Self, other: Self)
impl Clone for LengthHint
fn clone(self: &Self) -> LengthHint
impl Copy for LengthHint
impl Debug for LengthHint
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for LengthHint
impl Freeze for LengthHint
impl Mul for LengthHint
fn mul(self: Self, other: usize) -> Self
impl MulAssign for LengthHint
fn mul_assign(self: &mut Self, other: usize)
impl PartialEq for LengthHint
fn eq(self: &Self, other: &LengthHint) -> bool
impl RefUnwindSafe for LengthHint
impl Send for LengthHint
impl StructuralPartialEq for LengthHint
impl Sum for LengthHint
fn sum<I>(iter: I) -> Self where I: Iterator<Item = LengthHint>
impl Sum for LengthHint
fn sum<I>(iter: I) -> Self where I: Iterator<Item = usize>
impl Sync for LengthHint
impl Unpin for LengthHint
impl UnsafeUnpin for LengthHint
impl UnwindSafe for LengthHint
impl<T> Any for LengthHint
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for LengthHint
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for LengthHint
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for LengthHint
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for LengthHint
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for LengthHint
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for LengthHint
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for LengthHint
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for LengthHint
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>