Skip to content

Commit

Permalink
Replace thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
Felerius committed Feb 5, 2025
1 parent 6e1e6c8 commit 2ce0ea3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ chrono = "0.4.39"
rand = { version = "0.9.0", optional = true }
regex = "1.11.1"
serde = { version = "1.0.217", features = ["derive"], default-features = false }
thiserror = "2.0.11"

[dev-dependencies]
serde_test = "1.0.176"
Expand Down
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ use regex::Regex;
use serde::de::Visitor;
use serde::Deserialize;
use serde::Serialize;
use thiserror::Error;

/// A point in time.
///
Expand Down Expand Up @@ -425,12 +424,22 @@ impl Debug for Time {
}
}

#[derive(Error, Debug, Eq, PartialEq, Clone, Copy)]
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum TimeWindowError {
#[error("time window start is after end")]
StartAfterEnd,
}

impl Display for TimeWindowError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let message = match self {
Self::StartAfterEnd => "time window start is after end",
};
write!(f, "{message}")
}
}

impl Error for TimeWindowError {}

/// An interval or range of time: `[start,end)`.
/// Debug-asserts ensure that start <= end.
/// If compiled in release mode, the invariant of start <= end is maintained, by
Expand Down

0 comments on commit 2ce0ea3

Please sign in to comment.