@@ -404,11 +404,15 @@ impl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeFormatter<
404
404
/// .cast_into_fset::<CompositeFieldSet>();
405
405
///
406
406
/// // Create a date and convert it to the correct calendar:
407
- /// let date = Date::try_new_iso(2025, 3, 7).unwrap().to_calendar(Buddhist);
408
- ///
409
- /// // Extract the fields and use it with format_unchecked:
410
407
/// let mut input = DateTimeInputUnchecked::default();
411
- /// input.set_date_fields(date);
408
+ /// let date = Date::try_new_iso(2025, 3, 7)
409
+ /// .unwrap()
410
+ /// .to_calendar(Buddhist);
411
+ ///
412
+ /// // Safe because the calendar matches the formatter:
413
+ /// input.set_date_fields_unchecked(date);
414
+ ///
415
+ /// // Safe because YMD needs only date fields, which are in the input:
412
416
/// let result = formatter.format_unchecked(input);
413
417
///
414
418
/// assert_try_writeable_eq!(result, "7 มีนาคม 2568");
@@ -810,11 +814,15 @@ impl<FSet: DateTimeNamesMarker> DateTimeFormatter<FSet> {
810
814
/// .cast_into_fset::<CompositeFieldSet>();
811
815
///
812
816
/// // Create a date and convert it to the correct calendar:
813
- /// let date = Date::try_new_iso(2025, 3, 7).unwrap().to_calendar(formatter.calendar());
814
- ///
815
- /// // Extract the fields and use it with format_unchecked:
816
817
/// let mut input = DateTimeInputUnchecked::default();
817
- /// input.set_date_fields(date);
818
+ /// let date = Date::try_new_iso(2025, 3, 7)
819
+ /// .unwrap()
820
+ /// .to_calendar(formatter.calendar());
821
+ ///
822
+ /// // Safe because the calendar matches the formatter:
823
+ /// input.set_date_fields_unchecked(date);
824
+ ///
825
+ /// // Safe because YMD needs only date fields, which are in the input:
818
826
/// let result = formatter.format_unchecked(input);
819
827
///
820
828
/// assert_try_writeable_eq!(result, "7 มีนาคม 2568");
0 commit comments