pub trait CalendarDate: Sized + Display {
const MIN: Self;
const MAX: Self;
// Required methods
fn as_julian(&self) -> i32;
fn from_julian(value: i32) -> Option<Self>;
// Provided methods
fn tomorrow(self) -> Option<Self> { ... }
fn yesterday(self) -> Option<Self> { ... }
fn convert<T: CalendarDate>(self) -> T { ... }
}Expand description
A minimum set of functionality a typical calendar should provide.
Required Associated Constants§
Required Methods§
Sourcefn from_julian(value: i32) -> Option<Self>
fn from_julian(value: i32) -> Option<Self>
Get the date from the corresponding Julian
Provided Methods§
Sourcefn convert<T: CalendarDate>(self) -> T
fn convert<T: CalendarDate>(self) -> T
Converts the calendar date to a different calendar system.
§Examples
use sac13::prelude::*;
use sac13::day_counts::*;
let date_sac13 : Date = JulianDay::new(2460000).unwrap().convert();
let date_greg : GregorianDate = date_sac13.convert();It’s basically like the From trait, but because of the orphan rule I failed
to implement it generically for all types that implement CalendarDate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.