From 2703ca2d20ecb986b97bea03fe0f8d67ef9d3850 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Tue, 13 Feb 2024 16:36:08 +0100 Subject: [PATCH] Use `NonZeroI32::new_unchecked` --- src/naive/date/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/naive/date/mod.rs b/src/naive/date/mod.rs index 6b677e63..4ab09e1e 100644 --- a/src/naive/date/mod.rs +++ b/src/naive/date/mod.rs @@ -1398,10 +1398,11 @@ impl NaiveDate { /// Create a new `NaiveDate` from a raw year-ordinal-flags `i32`. /// /// In a valid value an ordinal is never `0`, and neither are the year flags. This method - /// doesn't do any validation; it only panics if the value is `0`. + /// doesn't do any validation. #[inline] const fn from_yof(yof: i32) -> NaiveDate { - NaiveDate { yof: expect!(NonZeroI32::new(yof), "invalid internal value") } + debug_assert!(yof != 0); + NaiveDate { yof: unsafe { NonZeroI32::new_unchecked(yof) } } } /// Get the raw year-ordinal-flags `i32`.