pub struct IanaParserBorrowed<'a> { /* private fields */ }Expand description
A borrowed wrapper around the time zone ID parser, returned by
IanaParser::as_borrowed(). More efficient to query.
Implementations§
Source§impl IanaParserBorrowed<'static>
 
impl IanaParserBorrowed<'static>
Sourcepub fn new() -> Self
 
pub fn new() -> Self
Creates a new IanaParserBorrowed using compiled data.
See IanaParserBorrowed for an example.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn static_to_owned(&self) -> IanaParser
 
pub fn static_to_owned(&self) -> IanaParser
Cheaply converts a [IanaParserBorrowed<'static>] into a IanaParser.
Note: Due to branching and indirection, using IanaParser might inhibit some
compile-time optimizations that are possible with IanaParserBorrowed.
Source§impl<'a> IanaParserBorrowed<'a>
 
impl<'a> IanaParserBorrowed<'a>
Sourcepub fn parse(&self, iana_id: &str) -> TimeZone
 
pub fn parse(&self, iana_id: &str) -> TimeZone
Gets the TimeZone from a case-insensitive IANA time zone ID.
Returns TimeZone::UNKNOWN if the IANA ID is not found.
§Examples
use icu_time::zone::iana::IanaParser;
use icu_time::TimeZone;
let parser = IanaParser::new();
let result = parser.parse("Asia/CALCUTTA");
assert_eq!(result.as_str(), "inccu");
// Unknown IANA time zone ID:
assert_eq!(parser.parse("America/San_Francisco"), TimeZone::UNKNOWN);Sourcepub fn parse_from_utf8(&self, iana_id: &[u8]) -> TimeZone
 
pub fn parse_from_utf8(&self, iana_id: &[u8]) -> TimeZone
Same as Self::parse() but works with potentially ill-formed UTF-8.
Sourcepub fn iter(&self) -> TimeZoneIter<'a> ⓘ
 
pub fn iter(&self) -> TimeZoneIter<'a> ⓘ
Returns an iterator over all known time zones.
§Examples
use icu::locale::subtags::subtag;
use icu::time::zone::IanaParser;
use icu::time::zone::TimeZone;
use std::collections::BTreeSet;
let parser = IanaParser::new();
let ids = parser.iter().collect::<BTreeSet<_>>();
assert!(ids.contains(&TimeZone(subtag!("uaiev"))));Trait Implementations§
Source§impl<'a> Clone for IanaParserBorrowed<'a>
 
impl<'a> Clone for IanaParserBorrowed<'a>
Source§fn clone(&self) -> IanaParserBorrowed<'a>
 
fn clone(&self) -> IanaParserBorrowed<'a>
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<'a> Debug for IanaParserBorrowed<'a>
 
impl<'a> Debug for IanaParserBorrowed<'a>
Source§impl Default for IanaParserBorrowed<'static>
 
impl Default for IanaParserBorrowed<'static>
impl<'a> Copy for IanaParserBorrowed<'a>
Auto Trait Implementations§
impl<'a> Freeze for IanaParserBorrowed<'a>
impl<'a> RefUnwindSafe for IanaParserBorrowed<'a>
impl<'a> Send for IanaParserBorrowed<'a>
impl<'a> Sync for IanaParserBorrowed<'a>
impl<'a> Unpin for IanaParserBorrowed<'a>
impl<'a> UnwindSafe for IanaParserBorrowed<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more