Struct icu_properties::WordBreak
source · #[repr(transparent)]pub struct WordBreak(pub u8);
Expand description
Enumerated property Word_Break.
See “Default Word Boundary Specification” in UAX #29 for the summary of each property value: https://www.unicode.org/reports/tr29/#Default_Word_Boundaries.
The numeric value is compatible with UWordBreakValues
in ICU4C.
Tuple Fields§
§0: u8
Implementations§
source§impl WordBreak
impl WordBreak
pub const Other: WordBreak = _
pub const ALetter: WordBreak = _
pub const Format: WordBreak = _
pub const Katakana: WordBreak = _
pub const MidLetter: WordBreak = _
pub const MidNum: WordBreak = _
pub const Numeric: WordBreak = _
pub const ExtendNumLet: WordBreak = _
pub const CR: WordBreak = _
pub const Extend: WordBreak = _
pub const LF: WordBreak = _
pub const MidNumLet: WordBreak = _
pub const Newline: WordBreak = _
pub const RegionalIndicator: WordBreak = _
pub const HebrewLetter: WordBreak = _
pub const SingleQuote: WordBreak = _
pub const DoubleQuote: WordBreak = _
sourcepub const GlueAfterZwj: WordBreak = _
pub const GlueAfterZwj: WordBreak = _
This value is obsolete and unused.
pub const ZWJ: WordBreak = _
pub const WSegSpace: WordBreak = _
source§impl WordBreak
impl WordBreak
sourcepub fn get_name_to_enum_mapper(
provider: &impl DataProvider<WordBreakNameToValueV1Marker> + ?Sized
) -> Result<PropertyValueNameToEnumMapper<WordBreak>, PropertiesError>
pub fn get_name_to_enum_mapper( provider: &impl DataProvider<WordBreakNameToValueV1Marker> + ?Sized ) -> Result<PropertyValueNameToEnumMapper<WordBreak>, PropertiesError>
Return a PropertyValueNameToEnumMapper
, capable of looking up values
from strings for the Word_Break
enumerated property
Example
use icu::properties::WordBreak;
let lookup = WordBreak::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("KA"), Some(WordBreak::Katakana));
assert_eq!(lookup.get_strict("LE"), Some(WordBreak::ALetter));
// long name for value
assert_eq!(lookup.get_strict("Katakana"), Some(WordBreak::Katakana));
assert_eq!(lookup.get_strict("ALetter"), Some(WordBreak::ALetter));
// name has incorrect casing
assert_eq!(lookup.get_strict("Aletter"), None);
// loose matching of name
assert_eq!(lookup.get_loose("Aletter"), Some(WordBreak::ALetter));
// fake property
assert_eq!(lookup.get_strict("Quadruple_Quote"), None);
sourcepub fn get_enum_to_short_name_mapper(
provider: &impl DataProvider<WordBreakValueToShortNameV1Marker> + ?Sized
) -> Result<PropertyEnumToValueNameLinearMapper<WordBreak>, PropertiesError>
pub fn get_enum_to_short_name_mapper( provider: &impl DataProvider<WordBreakValueToShortNameV1Marker> + ?Sized ) -> Result<PropertyEnumToValueNameLinearMapper<WordBreak>, PropertiesError>
Return a PropertyEnumToValueNameLinearMapper
, capable of looking up short names
for values of the Word_Break
enumerated property
Example
use icu::properties::WordBreak;
let lookup = WordBreak::get_enum_to_short_name_mapper(&icu_testdata::unstable())
.expect("The data should be valid");
let lookup = lookup.as_borrowed();
assert_eq!(lookup.get(WordBreak::Katakana), Some("KA"));
assert_eq!(lookup.get(WordBreak::ALetter), Some("LE"));
sourcepub fn get_enum_to_long_name_mapper(
provider: &impl DataProvider<WordBreakValueToLongNameV1Marker> + ?Sized
) -> Result<PropertyEnumToValueNameLinearMapper<WordBreak>, PropertiesError>
pub fn get_enum_to_long_name_mapper( provider: &impl DataProvider<WordBreakValueToLongNameV1Marker> + ?Sized ) -> Result<PropertyEnumToValueNameLinearMapper<WordBreak>, PropertiesError>
Return a PropertyEnumToValueNameLinearMapper
, capable of looking up long names
for values of the Word_Break
enumerated property
Example
use icu::properties::WordBreak;
let lookup = WordBreak::get_enum_to_long_name_mapper(&icu_testdata::unstable())
.expect("The data should be valid");
let lookup = lookup.as_borrowed();
assert_eq!(lookup.get(WordBreak::Katakana), Some("Katakana"));
assert_eq!(lookup.get(WordBreak::ALetter), Some("ALetter"));
Trait Implementations§
source§impl<'de> Deserialize<'de> for WordBreak
impl<'de> Deserialize<'de> for WordBreak
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 WordBreak
impl Ord for WordBreak
source§impl PartialEq<WordBreak> for WordBreak
impl PartialEq<WordBreak> for WordBreak
source§impl PartialOrd<WordBreak> for WordBreak
impl PartialOrd<WordBreak> for WordBreak
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 TrieValue for WordBreak
impl TrieValue for WordBreak
§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.