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

Undefined

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())
}

Returns whether the LengthHint indicates that the string is exactly 0 bytes long.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.