pub struct TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a> { /* private fields */ }
Expand description
A borrowed wrapper around the time zone ID mapper, returned by
TimeZoneIdMapperWithFastCanonicalization::as_borrowed()
. More efficient to query.
Implementations§
source§impl TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
impl TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
sourcepub fn new() -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
pub fn new() -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
Creates a new TimeZoneIdMapperWithFastCanonicalizationBorrowed
using compiled data.
See TimeZoneIdMapperWithFastCanonicalizationBorrowed
for an example.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn static_to_owned(
&self,
) -> TimeZoneIdMapperWithFastCanonicalization<TimeZoneIdMapper>
pub fn static_to_owned( &self, ) -> TimeZoneIdMapperWithFastCanonicalization<TimeZoneIdMapper>
Cheaply converts a [TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
] into a TimeZoneIdMapperWithFastCanonicalization
.
Note: Due to branching and indirection, using TimeZoneIdMapperWithFastCanonicalization
might inhibit some
compile-time optimizations that are possible with TimeZoneIdMapperWithFastCanonicalizationBorrowed
.
source§impl<'a> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
sourcepub fn inner(&self) -> TimeZoneIdMapperBorrowed<'a>
pub fn inner(&self) -> TimeZoneIdMapperBorrowed<'a>
Gets the inner TimeZoneIdMapperBorrowed
for performing queries.
sourcepub fn canonicalize_iana(
&self,
iana_id: &str,
) -> Option<(&str, TimeZoneBcp47Id)>
pub fn canonicalize_iana( &self, iana_id: &str, ) -> Option<(&str, TimeZoneBcp47Id)>
Returns the canonical, normalized identifier of the given IANA time zone.
Also returns the BCP-47 time zone ID.
This is a faster version of TimeZoneIdMapperBorrowed::canonicalize_iana()
and it always returns borrowed IANA strings, but it requires loading additional data
(see TimeZoneIdMapperWithFastCanonicalization
).
Returns None
if the IANA ID is not found.
§Examples
use icu_timezone::TimeZoneBcp47Id;
use icu_timezone::TimeZoneIdMapperWithFastCanonicalization;
use std::borrow::Cow;
let mapper = TimeZoneIdMapperWithFastCanonicalization::new();
let result = mapper.canonicalize_iana("Asia/CALCUTTA").unwrap();
// The Cow is always returned borrowed:
assert_eq!(result.0, "Asia/Kolkata");
assert_eq!(*result.1, "inccu");
// Unknown IANA time zone ID:
assert_eq!(mapper.canonicalize_iana("America/San_Francisco"), None);
sourcepub fn canonical_iana_from_bcp47(
&self,
bcp47_id: TimeZoneBcp47Id,
) -> Option<&str>
pub fn canonical_iana_from_bcp47( &self, bcp47_id: TimeZoneBcp47Id, ) -> Option<&str>
Returns the canonical, normalized IANA ID of the given BCP-47 ID.
This is a faster version of TimeZoneIdMapperBorrowed::find_canonical_iana_from_bcp47()
and it always returns borrowed IANA strings, but it requires loading additional data
(see TimeZoneIdMapperWithFastCanonicalization
).
Returns None
if the BCP-47 ID is not found.
§Examples
use icu_timezone::TimeZoneBcp47Id;
use icu_timezone::TimeZoneIdMapperWithFastCanonicalization;
use std::borrow::Cow;
use tinystr::tinystr;
let mapper = TimeZoneIdMapperWithFastCanonicalization::new();
let bcp47_id = TimeZoneBcp47Id(tinystr!(8, "inccu"));
let result = mapper.canonical_iana_from_bcp47(bcp47_id).unwrap();
// The Cow is always returned borrowed:
assert_eq!(result, "Asia/Kolkata");
// Unknown BCP-47 time zone ID:
let bcp47_id = TimeZoneBcp47Id(tinystr!(8, "ussfo"));
assert_eq!(mapper.canonical_iana_from_bcp47(bcp47_id), None);
Trait Implementations§
source§impl<'a> Clone for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> Clone for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
source§fn clone(&self) -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
fn clone(&self) -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> Debug for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
source§impl Default for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
impl Default for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
source§fn default() -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
fn default() -> TimeZoneIdMapperWithFastCanonicalizationBorrowed<'static>
impl<'a> Copy for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
Auto Trait Implementations§
impl<'a> Freeze for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> RefUnwindSafe for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> Send for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> Sync for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> Unpin for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'a>
impl<'a> UnwindSafe for TimeZoneIdMapperWithFastCanonicalizationBorrowed<'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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
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>
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