icu::time::zone::iana

Struct IanaParserBorrowed

Source
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>

Source

pub fn new() -> IanaParserBorrowed<'static>

Creates a new IanaParserBorrowed using compiled data.

See IanaParserBorrowed for an example.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

Source

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>

Source

pub fn parse(&self, iana_id: &str) -> TimeZone

Gets the BCP-47 time zone ID from an IANA time zone ID with a case-insensitive lookup.

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, "inccu");

// Unknown IANA time zone ID:
assert_eq!(parser.parse("America/San_Francisco"), TimeZone::unknown());
Source

pub fn parse_from_utf8(&self, iana_id: &[u8]) -> TimeZone

Same as Self::parse() but works with potentially ill-formed UTF-8.

Source

pub fn iter(&self) -> TimeZoneIter<'a>

Returns an iterator over all known time zones.

§Examples
use icu::time::zone::IanaParser;
use icu::time::zone::TimeZone;
use std::collections::BTreeSet;
use tinystr::tinystr;

let parser = IanaParser::new();

let ids = parser.iter().collect::<BTreeSet<_>>();

assert!(ids.contains(&TimeZone(tinystr!(8, "uaiev"))));

Trait Implementations§

Source§

impl<'a> Clone for IanaParserBorrowed<'a>

Source§

fn clone(&self) -> IanaParserBorrowed<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for IanaParserBorrowed<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for IanaParserBorrowed<'static>

Source§

fn default() -> IanaParserBorrowed<'static>

Returns the “default value” for a type. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,