Skip to content

Commit

Permalink
Cleaned up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri6037 committed Mar 1, 2024
1 parent 25292ff commit cc82c4f
Showing 1 changed file with 0 additions and 96 deletions.
96 changes: 0 additions & 96 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,99 +147,3 @@ impl<T> OffsetError<T> {
}

pub type OffsetResult<T> = Result<T, OffsetError<T>>;

/*/// This represents the possible types of errors when trying to find a local offset.
#[derive(Clone, Copy, Debug)]
pub enum OffsetResult<T> {
/// The date time is not ambiguous (exactly 1 is possible).
Some(T),
/// The date time is ambiguous (2 are possible).
Ambiguous(T, T),
/// The date time is invalid.
None,
}
impl<T> OffsetResult<T> {
/// Unwraps this OffsetResult assuming ambiguity is an error.
pub fn unwrap(self) -> T {
match self {
OffsetResult::Some(v) => v,
OffsetResult::Ambiguous(_, _) => panic!("Attempt to unwrap an ambiguous offset"),
OffsetResult::None => panic!("Attempt to unwrap an invalid offset"),
}
}
/// Unwraps this OffsetResult resolving ambiguity by taking the first result.
pub fn unwrap_first(self) -> T {
match self {
OffsetResult::Some(v) => v,
OffsetResult::Ambiguous(v, _) => v,
OffsetResult::None => panic!("Attempt to unwrap an invalid offset"),
}
}
/// Unwraps this OffsetResult resolving ambiguity by taking the second result.
pub fn unwrap_second(self) -> T {
match self {
OffsetResult::Some(v) => v,
OffsetResult::Ambiguous(_, v) => v,
OffsetResult::None => panic!("Attempt to unwrap an invalid offset"),
}
}
/// Turns this OffsetResult into an Option assuming ambiguity is an error.
pub fn take(self) -> Option<T> {
match self {
OffsetResult::Some(v) => Some(v),
OffsetResult::Ambiguous(_, _) => None,
OffsetResult::None => None,
}
}
/// Turns this OffsetResult into an Option resolving ambiguity by taking the first result.
pub fn take_first(self) -> Option<T> {
match self {
OffsetResult::Some(v) => Some(v),
OffsetResult::Ambiguous(v, _) => Some(v),
OffsetResult::None => None,
}
}
/// Turns this OffsetResult into an Option resolving ambiguity by taking the second result.
pub fn take_second(self) -> Option<T> {
match self {
OffsetResult::Some(v) => Some(v),
OffsetResult::Ambiguous(_, v) => Some(v),
OffsetResult::None => None,
}
}
/// Returns true if this OffsetResult is None.
pub fn is_none(&self) -> bool {
match self {
OffsetResult::Some(_) => false,
OffsetResult::Ambiguous(_, _) => false,
OffsetResult::None => true,
}
}
/// Returns true if this OffsetResult is ambiguous.
pub fn is_ambiguous(&self) -> bool {
match self {
OffsetResult::Some(_) => false,
OffsetResult::Ambiguous(_, _) => true,
OffsetResult::None => false,
}
}
/// Maps this OffsetResult to a different result type.
pub fn map<R, F: Fn(&T) -> R>(&self, f: F) -> OffsetResult<R> {
match self {
OffsetResult::Some(a) => OffsetResult::Some(f(a)),
OffsetResult::Ambiguous(a, b) => OffsetResult::Ambiguous(f(a), f(b)),
OffsetResult::None => OffsetResult::None,
}
}
}*/

0 comments on commit cc82c4f

Please sign in to comment.