icu_time/scaffold/
into_option.rs
use crate::{
zone::{TimeZoneVariant, UtcOffset},
Hour, Minute, Nanosecond, Second, Time, TimeZone,
};
use icu_calendar::{types::*, AnyCalendarKind, Date, Iso};
pub trait IntoOption<T> {
fn into_option(self) -> Option<T>;
}
impl<T> IntoOption<T> for Option<T> {
#[inline]
fn into_option(self) -> Option<T> {
self
}
}
impl<T> IntoOption<T> for () {
#[inline]
fn into_option(self) -> Option<T> {
None
}
}
impl IntoOption<YearInfo> for YearInfo {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<MonthInfo> for MonthInfo {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<DayOfMonth> for DayOfMonth {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<Weekday> for Weekday {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<DayOfYearInfo> for DayOfYearInfo {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<AnyCalendarKind> for AnyCalendarKind {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<Hour> for Hour {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<Minute> for Minute {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<Second> for Second {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<Nanosecond> for Nanosecond {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<TimeZone> for TimeZone {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<UtcOffset> for UtcOffset {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<TimeZoneVariant> for TimeZoneVariant {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}
impl IntoOption<(Date<Iso>, Time)> for (Date<Iso>, Time) {
#[inline]
fn into_option(self) -> Option<Self> {
Some(self)
}
}