Enum smartcow::SmartCow[][src]

pub enum SmartCow<'a> {
    Borrowed(&'a str),
    Owned(SmartString<LazyCompact>),
}
Expand description

The primary type for this crate, which holds either a borrowed str or a SmartString

Variants

Borrowed

a std::str borrow

Tuple Fields of Borrowed

0: &'a str
Owned

Tuple Fields of Owned

0: SmartString<LazyCompact>

Implementations

Build a ’static duplicate of this SmartCow by cloning a reference. If you own the SmartCow, SmartCow::into_owned is preferable, as it will not allocate an unnecesssary owned value.

This is identical to calling self.clone().into_owned(), which first allocates in the case of an owned variant by cloning, and then allocates in the case of a borrowed variant, with into_owned.

Build a ’static duplicate of this SmartCow by value, by allocating a SmartString if self is a SmartCow::Borrowed variant. If you do not have ownership of a SmartCow and need to create a ’static SmartCow from it by reference, use SmartCow::to_owned

Trait Implementations

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Converts the given value to a String. 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.