Open
Description
I was just reading your code and was wondering what's up with the Day::__new_unchecked
function.
Wouldn't it make more sense to "really" expose it publicly and make it unsafe, so that the caller has to take care to uphold safety?
diff --git a/src/template/day.rs b/src/template/day.rs
--- a/src/template/day.rs
+++ b/src/template/day.rs
@@ -31,9 +31,12 @@ impl Day {
Some(Self(day))
}
- // Not part of the public API
- #[doc(hidden)]
- pub const fn __new_unchecked(day: u8) -> Self {
+ /// Creates a new day without checking if it's in the valid range.
+ ///
+ /// # Safety
+ ///
+ /// Ensure that day is in range `1..=24`.
+ pub const unsafe fn new_unchecked(day: u8) -> Self {
Self(day)
}
@@ -146,7 +149,7 @@ macro_rules! day {
"`, expecting a value between 1 and 25"
),
);
- $crate::template::Day::__new_unchecked($day)
+ unsafe { $crate::template::Day::new_unchecked($day) }
}};
}
Metadata
Metadata
Assignees
Labels
No labels