Function date
const fn date(year: i16, month: i8, day: i8) -> Date
Creates a new Date value in a const context.
This is a convenience free function for Date::constant. It is intended
to provide a terse syntax for constructing Date values from parameters
that are known to be valid.
Panics
This routine panics when Date::new would return an error. That is,
when the given year-month-day does not correspond to a valid date.
Namely, all of the following must be true:
- The year must be in the range
-9999..=9999. - The month must be in the range
1..=12. - The day must be at least
1and must be at most the number of days in the corresponding month. So for example,2024-02-29is valid but2023-02-29is not.
Similarly, when used in a const context, invalid parameters will prevent your Rust program from compiling.
Example
use date;
let d = date;
assert_eq!;
assert_eq!;
assert_eq!;