Add doc comments on expect_in_range and PartialEq<Zoned>

Document that expect_in_range is intended for tests/trusted contexts
and that Extended values never compare equal to a Zoned.
This commit is contained in:
Sylvestre Ledru
2026-03-31 09:14:23 +02:00
parent f7aa4540c9
commit 2efa5c1d7b
+6
View File
@@ -49,6 +49,11 @@ impl ParsedDateTime {
} }
} }
/// Unwraps the `InRange` variant, panicking if this is an `Extended` value.
///
/// This is a convenience for contexts where the caller is certain the result
/// is in range (e.g., tests). Prefer [`into_zoned`](Self::into_zoned) or
/// pattern matching in production code.
pub fn expect_in_range(self) -> Zoned { pub fn expect_in_range(self) -> Zoned {
self.into_zoned() self.into_zoned()
.expect("ParsedDateTime is not representable as jiff::Zoned") .expect("ParsedDateTime is not representable as jiff::Zoned")
@@ -64,6 +69,7 @@ impl fmt::Display for ParsedDateTime {
} }
} }
/// An `Extended` value never compares equal to a `Zoned`.
impl PartialEq<Zoned> for ParsedDateTime { impl PartialEq<Zoned> for ParsedDateTime {
fn eq(&self, other: &Zoned) -> bool { fn eq(&self, other: &Zoned) -> bool {
match self { match self {