File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change @@ -24,19 +24,13 @@ pub struct Day(u8);
2424impl Day {
2525 /// Creates a [`Day`] from the provided value if it's in the valid range,
2626 /// returns [`None`] otherwise.
27- pub fn new ( day : u8 ) -> Option < Self > {
27+ pub const fn new ( day : u8 ) -> Option < Self > {
2828 if day == 0 || day > 25 {
2929 return None ;
3030 }
3131 Some ( Self ( day) )
3232 }
3333
34- // Not part of the public API
35- #[ doc( hidden) ]
36- pub const fn __new_unchecked ( day : u8 ) -> Self {
37- Self ( day)
38- }
39-
4034 /// Converts the [`Day`] into an [`u8`].
4135 pub fn into_inner ( self ) -> u8 {
4236 self . 0
@@ -137,17 +131,12 @@ impl Iterator for AllDays {
137131/// Creates a [`Day`] value in a const context.
138132#[ macro_export]
139133macro_rules! day {
140- ( $day: expr) => { {
141- const _ASSERT: ( ) = assert!(
142- $day != 0 && $day <= 25 ,
143- concat!(
144- "invalid day number `" ,
145- $day,
146- "`, expecting a value between 1 and 25"
147- ) ,
148- ) ;
149- $crate:: template:: Day :: __new_unchecked( $day)
150- } } ;
134+ ( $day: expr) => {
135+ const {
136+ $crate:: template:: Day :: new( $day)
137+ . expect( "invalid day number, expecting a value between 1 and 25" )
138+ }
139+ } ;
151140}
152141
153142/* -------------------------------------------------------------------------- */
You can’t perform that action at this time.
0 commit comments