Struct icu_properties::EastAsianWidth
source · #[repr(transparent)]pub struct EastAsianWidth(pub u8);
Expand description
Enumerated property East_Asian_Width.
See “Definition” in UAX #11 for the summary of each property value: https://www.unicode.org/reports/tr11/#Definitions
The numeric value is compatible with UEastAsianWidth
in ICU4C.
Tuple Fields§
§0: u8
Implementations§
source§impl EastAsianWidth
impl EastAsianWidth
pub const Neutral: EastAsianWidth = _
pub const Ambiguous: EastAsianWidth = _
pub const Halfwidth: EastAsianWidth = _
pub const Fullwidth: EastAsianWidth = _
pub const Narrow: EastAsianWidth = _
pub const Wide: EastAsianWidth = _
source§impl EastAsianWidth
impl EastAsianWidth
sourcepub fn get_name_to_enum_mapper(
provider: &impl DataProvider<EastAsianWidthNameToValueV1Marker> + ?Sized
) -> Result<PropertyValueNameToEnumMapper<EastAsianWidth>, PropertiesError>
pub fn get_name_to_enum_mapper( provider: &impl DataProvider<EastAsianWidthNameToValueV1Marker> + ?Sized ) -> Result<PropertyValueNameToEnumMapper<EastAsianWidth>, PropertiesError>
Return a PropertyValueNameToEnumMapper
, capable of looking up values
from strings for the East_Asian_Width
enumerated property
Example
use icu::properties::EastAsianWidth;
let lookup = EastAsianWidth::get_name_to_enum_mapper(&icu_testdata::unstable())
.expect("The data should be valid");
let lookup = lookup.as_borrowed();
// short name for value
assert_eq!(lookup.get_strict("N"), Some(EastAsianWidth::Neutral));
assert_eq!(lookup.get_strict("H"), Some(EastAsianWidth::Halfwidth));
// long name for value
assert_eq!(lookup.get_strict("Neutral"), Some(EastAsianWidth::Neutral));
assert_eq!(lookup.get_strict("Halfwidth"), Some(EastAsianWidth::Halfwidth));
// name has incorrect casing / extra hyphen
assert_eq!(lookup.get_strict("half-width"), None);
// loose matching of name
assert_eq!(lookup.get_loose("half-width"), Some(EastAsianWidth::Halfwidth));
// fake property
assert_eq!(lookup.get_strict("TwoPointFiveWidth"), None);
sourcepub fn get_enum_to_short_name_mapper(
provider: &impl DataProvider<EastAsianWidthValueToShortNameV1Marker> + ?Sized
) -> Result<PropertyEnumToValueNameLinearMapper<EastAsianWidth>, PropertiesError>
pub fn get_enum_to_short_name_mapper( provider: &impl DataProvider<EastAsianWidthValueToShortNameV1Marker> + ?Sized ) -> Result<PropertyEnumToValueNameLinearMapper<EastAsianWidth>, PropertiesError>
Return a PropertyEnumToValueNameLinearMapper
, capable of looking up short names
for values of the East_Asian_Width
enumerated property
Example
use icu::properties::EastAsianWidth;
let lookup = EastAsianWidth::get_enum_to_short_name_mapper(&icu_testdata::unstable())
.expect("The data should be valid");
let lookup = lookup.as_borrowed();
assert_eq!(lookup.get(EastAsianWidth::Neutral), Some("N"));
assert_eq!(lookup.get(EastAsianWidth::Halfwidth), Some("H"));
sourcepub fn get_enum_to_long_name_mapper(
provider: &impl DataProvider<EastAsianWidthValueToLongNameV1Marker> + ?Sized
) -> Result<PropertyEnumToValueNameLinearMapper<EastAsianWidth>, PropertiesError>
pub fn get_enum_to_long_name_mapper( provider: &impl DataProvider<EastAsianWidthValueToLongNameV1Marker> + ?Sized ) -> Result<PropertyEnumToValueNameLinearMapper<EastAsianWidth>, PropertiesError>
Return a PropertyEnumToValueNameLinearMapper
, capable of looking up long names
for values of the East_Asian_Width
enumerated property
Example
use icu::properties::EastAsianWidth;
let lookup = EastAsianWidth::get_enum_to_long_name_mapper(&icu_testdata::unstable())
.expect("The data should be valid");
let lookup = lookup.as_borrowed();
assert_eq!(lookup.get(EastAsianWidth::Neutral), Some("Neutral"));
assert_eq!(lookup.get(EastAsianWidth::Halfwidth), Some("Halfwidth"));
Trait Implementations§
source§impl AsULE for EastAsianWidth
impl AsULE for EastAsianWidth
source§impl Bake for EastAsianWidth
impl Bake for EastAsianWidth
source§fn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
source§impl Clone for EastAsianWidth
impl Clone for EastAsianWidth
source§fn clone(&self) -> EastAsianWidth
fn clone(&self) -> EastAsianWidth
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for EastAsianWidth
impl Debug for EastAsianWidth
source§impl<'de> Deserialize<'de> for EastAsianWidth
impl<'de> Deserialize<'de> for EastAsianWidth
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for EastAsianWidth
impl Ord for EastAsianWidth
source§fn cmp(&self, other: &EastAsianWidth) -> Ordering
fn cmp(&self, other: &EastAsianWidth) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<EastAsianWidth> for EastAsianWidth
impl PartialEq<EastAsianWidth> for EastAsianWidth
source§fn eq(&self, other: &EastAsianWidth) -> bool
fn eq(&self, other: &EastAsianWidth) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<EastAsianWidth> for EastAsianWidth
impl PartialOrd<EastAsianWidth> for EastAsianWidth
source§fn partial_cmp(&self, other: &EastAsianWidth) -> Option<Ordering>
fn partial_cmp(&self, other: &EastAsianWidth) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for EastAsianWidth
impl Serialize for EastAsianWidth
source§impl TrieValue for EastAsianWidth
impl TrieValue for EastAsianWidth
§type TryFromU32Error = TryFromIntError
type TryFromU32Error = TryFromIntError
Last-resort fallback value to return if we cannot read data from the trie. Read more
source§fn try_from_u32(i: u32) -> Result<Self, Self::TryFromU32Error>
fn try_from_u32(i: u32) -> Result<Self, Self::TryFromU32Error>
A parsing function that is primarily motivated by deserialization contexts.
When the serialization type width is smaller than 32 bits, then it is expected
that the call site will widen the value to a
u32
first.source§impl<'a> ZeroMapKV<'a> for EastAsianWidth
impl<'a> ZeroMapKV<'a> for EastAsianWidth
§type Container = ZeroVec<'a, EastAsianWidth>
type Container = ZeroVec<'a, EastAsianWidth>
The container that can be used with this type:
ZeroVec
or VarZeroVec
.type Slice = ZeroSlice<EastAsianWidth>
§type OwnedType = EastAsianWidth
type OwnedType = EastAsianWidth
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