Enum writeable::LengthHint [−][src]
pub enum LengthHint {
Undefined,
Exact(usize),
}
Expand description
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.
Tuple Fields of Exact
0: usize
Implementations
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())
}
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Method which takes an iterator and generates Self
from the elements by
“summing up” the items. Read more
Auto Trait Implementations
impl RefUnwindSafe for LengthHint
impl Send for LengthHint
impl Sync for LengthHint
impl Unpin for LengthHint
impl UnwindSafe for LengthHint
Blanket Implementations
Mutably borrows from an owned value. Read more