#[repr(transparent)]
pub struct Key(_);
Expand description

A key used in a list of Fields.

The key has to be a two ASCII characters long, with the first character being alphabetic, and the second being a number.

Examples

use icu::locid::extensions::transform::Key;

let key1: Key = "k0".parse().expect("Failed to parse a Key.");

assert_eq!(key1.as_str(), "k0");

Implementations

A constructor which takes a UTF-8 slice, parses it and produces a well-formed Key.

Examples
use icu_locid::extensions :: transform :: Key;

assert!(Key::try_from_bytes(b"k0").is_ok());
assert!(Key::try_from_bytes(b"").is_err());

Equivalent to try_from_bytes(bytes[start..end]), but callable in a const context (which range indexing is not).

Safely creates a Key from its raw format as returned by Self::into_raw. Unlike Self::try_from_bytes, this constructor only takes normalized values.

Unsafely creates a Key from its raw format as returned by Self::into_raw. Unlike Self::try_from_bytes, this constructor only takes normalized values.

Safety

This function is safe iff Self::try_from_raw returns an Ok. This is the case for inputs that are correctly normalized.

Deconstructs into a raw format to be consumed by from_raw_unchecked or try_from_raw.

A helper function for displaying as a &str.

Compare with BCP-47 bytes.

The return value is equivalent to what would happen if you first converted self to a BCP-47 string and then performed a byte comparison.

This function is case-sensitive and results in a total order, so it is appropriate for binary search. The only argument producing Ordering::Equal is self.as_str().as_bytes().

Compare with a potentially unnormalized BCP-47 string.

The return value is equivalent to what would happen if you first parsed the BCP-47 string and then performed a structural comparison.

Trait Implementations

The ULE type corresponding to Self. Read more

Converts from Self to Self::ULE. Read more

Converts from Self::ULE to Self. Read more

Returns a TokenStream that would evaluate to self. 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

Deserialize this value from the given Serde deserializer. Read more

This trait is implemented for compatibility with fmt!. To create a string, [Writeable::write_to_string] is usually more efficient.

Formats the value using the given formatter. Read more

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. 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 returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Validates a byte slice, &[u8]. Read more

Parses a byte slice, &[u8], and return it as &[Self] with the same lifetime. Read more

Takes a byte slice, &[u8], and return it as &[Self] with the same lifetime, assuming that this byte slice has previously been run through Self::parse_byte_slice() with success. Read more

Given &[Self], returns a &[u8] with the same lifetime. Read more

Writes a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to_parts, and discards any Part annotations. Read more

Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations. Read more

The container that can be used with this type: ZeroVec or VarZeroVec.

The type produced by Container::get() Read more

The type produced by Container::replace() and Container::remove(), also used during deserialization. If Self is human readable serialized, deserializing to Self::OwnedType should produce the same value once passed through Self::owned_as_self() 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Adds separators according to the given SeparatorPolicy. Read more

Inserts a comma every three digits from the right. Read more

Inserts a space every three digits from the right. Read more

Inserts a period every three digits from the right. Read more

Inserts an underscore every three digits from the right. Read more

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)

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.