Struct icu_locid::subtags::Script [−][src]
pub struct Script(_);
A script subtag (examples: "Latn"
, "Arab"
, etc.)
Script
represents a Unicode base language code conformat to the
unicode_script_id
field of the Language and Locale Identifier.
Examples
use icu::locid::subtags::Script; let script: Script = "Latn".parse() .expect("Failed to parse a script subtag.");
Implementations
impl Script
[src]
impl Script
[src]pub fn from_bytes(v: &[u8]) -> Result<Self, ParserError>
[src]
A constructor which takes a utf8 slice, parses it and
produces a well-formed Script
.
Examples
use icu::locid::subtags::Script; let script = Script::from_bytes(b"Latn") .expect("Parsing failed."); assert_eq!(script, "Latn");
pub fn into_raw(self) -> u32
[src]
Deconstructs the Script
into raw format to be consumed
by from_raw_unchecked()
.
Examples
use icu::locid::subtags::Script; let script = Script::from_bytes(b"Latn") .expect("Parsing failed."); let raw = script.into_raw(); let script = unsafe { Script::from_raw_unchecked(raw) }; assert_eq!(script, "Latn");
pub const unsafe fn from_raw_unchecked(v: u32) -> Self
[src]
Constructor which takes a raw value returned by
into_raw
.
Examples
use icu::locid::subtags::Script; let script = Script::from_bytes(b"Latn") .expect("Parsing failed."); let raw = script.into_raw(); let script = unsafe { Script::from_raw_unchecked(raw) }; assert_eq!(script, "Latn");
Safety
This function accepts a u32
that is expected to be a valid TinyStr4
representing a Script
subtag in canonical syntax.
pub fn as_str(&self) -> &str
[src]
A helper function for displaying
a Script
subtag as a &
str
.
Examples
use icu::locid::subtags::Script; let script = Script::from_bytes(b"Latn") .expect("Parsing failed."); assert_eq!(script.as_str(), "Latn");
Notice
: For many use cases, such as comparison,
Script
implements PartialEq
<&
str
>
which allows for direct comparisons.
Trait Implementations
impl PartialOrd<Script> for Script
[src]
impl PartialOrd<Script> for Script
[src]impl StructuralEq for Script
[src]
impl StructuralEq for Script
[src]impl StructuralPartialEq for Script
[src]
impl StructuralPartialEq for Script
[src]Auto Trait Implementations
impl RefUnwindSafe for Script
impl RefUnwindSafe for Script
impl UnwindSafe for Script
impl UnwindSafe for Script