pub struct MismatchedCalendarError;Expand description
Error returned when interacting two Dates with non-singleton calendars.
§Examples
use icu::calendar::Date;
use icu::calendar::error::MismatchedCalendarError;
use icu::calendar::options::DateDifferenceOptions;
use icu::calendar::options::DateDurationUnit;
let d1 = Date::try_new_gregorian(2000, 1, 1).unwrap().to_any();
let d2 = Date::try_new_persian(1562, 1, 1).unwrap().to_any();
assert_eq!(
d1.try_until_with_options(&d2, Default::default())
.unwrap_err(),
MismatchedCalendarError,
);
// To compare the dates, convert them to the same calendar.
// Note that the result may differ based on the calendar used,
// e.g if comparing in months and days.
let mut options = DateDifferenceOptions::default();
options.largest_unit = Some(DateDurationUnit::Months);
let diff1 = d1
.to_calendar(d2.calendar().clone())
.try_until_with_options(&d2, options)
.unwrap();
let diff2 = d1
.try_until_with_options(&d2.to_calendar(d1.calendar().clone()), options)
.unwrap();
assert_ne!(diff1, diff2);Trait Implementations§
Source§impl Clone for MismatchedCalendarError
impl Clone for MismatchedCalendarError
Source§fn clone(&self) -> MismatchedCalendarError
fn clone(&self) -> MismatchedCalendarError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MismatchedCalendarError
Source§impl Debug for MismatchedCalendarError
impl Debug for MismatchedCalendarError
Source§impl Display for MismatchedCalendarError
impl Display for MismatchedCalendarError
Source§impl Error for MismatchedCalendarError
impl Error for MismatchedCalendarError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for MismatchedCalendarError
impl PartialEq for MismatchedCalendarError
impl StructuralPartialEq for MismatchedCalendarError
Auto Trait Implementations§
impl Freeze for MismatchedCalendarError
impl RefUnwindSafe for MismatchedCalendarError
impl Send for MismatchedCalendarError
impl Sync for MismatchedCalendarError
impl Unpin for MismatchedCalendarError
impl UnsafeUnpin for MismatchedCalendarError
impl UnwindSafe for MismatchedCalendarError
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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