// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::{ zone::{TimeZoneVariant, UtcOffset, ZoneNameTimestamp}, Hour, Minute, Nanosecond, Second, TimeZone, }; use icu_calendar::{types::*, AnyCalendarKind}; /// Converts Self to an `Option`, either `Some(T)` if able or `None` pub trait IntoOption { /// Return `self` as an `Option` fn into_option(self) -> Option; } impl IntoOption for Option { #[inline] fn into_option(self) -> Option { self } } impl IntoOption for () { #[inline] fn into_option(self) -> Option { None } } impl IntoOption for YearInfo { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for MonthInfo { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for DayOfMonth { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for Weekday { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for DayOfYear { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for RataDie { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for AnyCalendarKind { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for Hour { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for Minute { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for Second { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for Nanosecond { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for TimeZone { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for UtcOffset { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for TimeZoneVariant { #[inline] fn into_option(self) -> Option { Some(self) } } impl IntoOption for ZoneNameTimestamp { #[inline] fn into_option(self) -> Option { Some(self) } }