mirror of
https://github.com/chronotope/chrono.git
synced 2026-05-04 13:34:10 +00:00
Use NonZeroI32::new_unchecked
This commit is contained in:
@@ -1398,10 +1398,11 @@ impl NaiveDate {
|
|||||||
/// Create a new `NaiveDate` from a raw year-ordinal-flags `i32`.
|
/// 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
|
/// 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]
|
#[inline]
|
||||||
const fn from_yof(yof: i32) -> NaiveDate {
|
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`.
|
/// Get the raw year-ordinal-flags `i32`.
|
||||||
|
|||||||
Reference in New Issue
Block a user