Struct SubdivisionSuffix

struct SubdivisionSuffix(_)

A subdivision suffix used in SubdivisionId.

This suffix represents a specific subdivision code under a given Region. For example the value of SubdivisionId may be gbsct, where the SubdivisionSuffix is sct for Scotland.

Such a value associated with a key rg means that the locale should use Unit Preferences (default calendar, currency, week data, time cycle, measurement system) for Scotland, even if the LanguageIdentifier is en-US.

A subdivision suffix has to be a sequence of alphanumerical characters no shorter than one and no longer than four characters.

Examples

use icu::locale::extensions::unicode::{subdivision_suffix, SubdivisionSuffix};

let ss: SubdivisionSuffix =
    "sct".parse().expect("Failed to parse a SubdivisionSuffix.");

assert_eq!(ss, subdivision_suffix!("sct"));

Implementations

impl SubdivisionSuffix

fn to_string(self: &Self) -> String

Converts the given value to a String.

Under the hood, this uses an efficient Writeable implementation. However, in order to avoid allocating a string, it is more efficient to use Writeable directly.

impl SubdivisionSuffix

const fn try_from_str(s: &str) -> Result<Self, ParseError>

A constructor which takes a str slice, parses it and produces a well-formed SubdivisionSuffix.

Examples

use icu_locale_core::extensions :: unicode ::SubdivisionSuffix;

assert!(SubdivisionSuffix::try_from_str("sct").is_ok());
assert!(SubdivisionSuffix::try_from_str("toolooong").is_err());
const fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>

See Self::try_from_str

const fn try_from_raw(raw: [u8; 4]) -> Result<Self, ParseError>

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

unsafe const fn from_raw_unchecked(v: [u8; 4]) -> Self

Unsafely creates a SubdivisionSuffix from its raw format as returned by Self::into_raw. Unlike Self::try_from_utf8, 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.

const fn into_raw(self: Self) -> [u8; 4]

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

const fn as_str(self: &Self) -> &str

A helper function for displaying as a &str.

fn strict_cmp(self: Self, other: &[u8]) -> Ordering

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

fn normalizing_eq(self: Self, other: &str) -> bool

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.

impl AsULE for SubdivisionSuffix

fn to_unaligned(self: Self) -> <Self as >::ULE
fn from_unaligned(unaligned: <Self as >::ULE) -> Self

impl Clone for SubdivisionSuffix

fn clone(self: &Self) -> SubdivisionSuffix

impl Copy for SubdivisionSuffix

impl Debug for SubdivisionSuffix

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Display for SubdivisionSuffix

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for SubdivisionSuffix

impl Freeze for SubdivisionSuffix

impl FromStr for SubdivisionSuffix

fn from_str(s: &str) -> Result<Self, <Self as >::Err>

impl Hash for SubdivisionSuffix

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl NicheBytes for SubdivisionSuffix

impl Ord for SubdivisionSuffix

fn cmp(self: &Self, other: &SubdivisionSuffix) -> Ordering

impl PartialEq for SubdivisionSuffix

fn eq(self: &Self, other: &SubdivisionSuffix) -> bool

impl PartialOrd for SubdivisionSuffix

fn partial_cmp(self: &Self, other: &SubdivisionSuffix) -> Option<Ordering>

impl RefUnwindSafe for SubdivisionSuffix

impl Send for SubdivisionSuffix

impl StructuralPartialEq for SubdivisionSuffix

impl Sync for SubdivisionSuffix

impl ULE for SubdivisionSuffix

fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>

impl Unpin for SubdivisionSuffix

impl UnsafeUnpin for SubdivisionSuffix

impl UnwindSafe for SubdivisionSuffix

impl Writeable for SubdivisionSuffix

fn write_to<W: core::fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> Result
fn writeable_length_hint(self: &Self) -> LengthHint

impl<'a> ZeroMapKV for SubdivisionSuffix

impl<T> Any for SubdivisionSuffix

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SubdivisionSuffix

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SubdivisionSuffix

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for SubdivisionSuffix

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for SubdivisionSuffix

impl<T> From for SubdivisionSuffix

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for SubdivisionSuffix

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for SubdivisionSuffix

fn to_string(self: &Self) -> String

impl<T, U> Into for SubdivisionSuffix

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for SubdivisionSuffix

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for SubdivisionSuffix

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>