Enum writeable::LengthHint [−][src]
pub enum LengthHint { Undefined, Exact(usize), }
A hint to help consumers of Writeable pre-allocate bytes before they call write_to.
LengthHint implements std::ops::Add and similar traits for easy composition.
See this issue for more info: https://github.com/unicode-org/icu4x/issues/370.
Variants
Default value: no hint is provided.
Exact(usize)
An exact length hint. This value is expected to equal the actual length from write_to.
Implementations
impl LengthHint
[src]
impl LengthHint
[src]pub fn capacity(&self) -> usize
[src]
Returns a recommendation for the number of bytes to pre-allocate.
Examples
use writeable::Writeable; fn pre_allocate_string(w: &impl Writeable) -> String { String::with_capacity(w.write_len().capacity()) }
pub fn is_zero(&self) -> bool
[src]
Returns whether the LengthHint indicates that the string is exactly 0 bytes long.
Trait Implementations
impl Add<LengthHint> for LengthHint
[src]
impl Add<LengthHint> for LengthHint
[src]type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: LengthHint) -> Self
[src]
impl Add<usize> for LengthHint
[src]
impl Add<usize> for LengthHint
[src]impl AddAssign<LengthHint> for LengthHint
[src]
impl AddAssign<LengthHint> for LengthHint
[src]fn add_assign(&mut self, other: Self)
[src]
impl AddAssign<usize> for LengthHint
[src]
impl AddAssign<usize> for LengthHint
[src]fn add_assign(&mut self, other: usize)
[src]
impl Clone for LengthHint
[src]
impl Clone for LengthHint
[src]fn clone(&self) -> LengthHint
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for LengthHint
[src]
impl Copy for LengthHint
[src]impl Eq for LengthHint
[src]
impl Eq for LengthHint
[src]impl PartialEq<LengthHint> for LengthHint
[src]
impl PartialEq<LengthHint> for LengthHint
[src]fn eq(&self, other: &LengthHint) -> bool
[src]
fn ne(&self, other: &LengthHint) -> bool
[src]
impl StructuralEq for LengthHint
[src]
impl StructuralEq for LengthHint
[src]impl StructuralPartialEq for LengthHint
[src]
impl StructuralPartialEq for LengthHint
[src]impl Sum<LengthHint> for LengthHint
[src]
impl Sum<LengthHint> for LengthHint
[src]fn sum<I>(iter: I) -> Self where
I: Iterator<Item = LengthHint>,
[src]
I: Iterator<Item = LengthHint>,
Auto Trait Implementations
impl RefUnwindSafe for LengthHint
impl RefUnwindSafe for LengthHint
impl Send for LengthHint
impl Send for LengthHint
impl Sync for LengthHint
impl Sync for LengthHint
impl Unpin for LengthHint
impl Unpin for LengthHint
impl UnwindSafe for LengthHint
impl UnwindSafe for LengthHint