Skip to content

Commit 6ad6fa4

Browse files
Rename wrap_calendar_in APIs (#6392)
Fixes #6027 <!-- Thank you for your pull request to ICU4X! Reminder: try to use [Conventional Comments](https://conventionalcomments.org/) to make comments clearer. Please see https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for general information on contributing to ICU4X. --> --------- Co-authored-by: Robert Bastian <[email protected]>
1 parent 5ff9a7d commit 6ad6fa4

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Some major changes worth highlighting:
1717
- Rename `Islamic` calendars to `Hijri` (unicode-org#6214)
1818
- Collapse `IslamicCivil` into `IslamicTabular` (unicode-org#6384)
1919
- Rename `IslamicObservational` to `IslamicSimulated`
20+
- Rename `wrap_calendar_in_*` APIs to `as_borrowed`, `into_ref_counted`, `into_atomic_ref_counted` (unicode-org#6392)
2021
- `icu_collections`
2122
- Remove some panics from `CodePointTrie`, which should no longer pull in panic machinery even with arithmetic panics enabled for lookup (unicode-org#6204)
2223
- Data model and providers

components/calendar/src/date.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,23 @@ impl<A: AsCalendar> Date<A> {
353353
///
354354
/// Useful when paired with [`Self::to_any()`] to obtain a `Date<Rc<AnyCalendar>>`
355355
#[cfg(feature = "alloc")]
356-
pub fn wrap_calendar_in_rc(self) -> Date<Rc<A>> {
356+
pub fn into_ref_counted(self) -> Date<Rc<A>> {
357357
Date::from_raw(self.inner, Rc::new(self.calendar))
358358
}
359359

360360
/// Wrap the calendar type in `Arc<T>`
361361
///
362-
/// Useful when paired with [`Self::to_any()`] to obtain a `Date<Rc<AnyCalendar>>`
362+
/// Useful when paired with [`Self::to_any()`] to obtain a `Date<Arc<AnyCalendar>>`
363363
#[cfg(feature = "alloc")]
364-
pub fn wrap_calendar_in_arc(self) -> Date<Arc<A>> {
364+
pub fn into_atomic_ref_counted(self) -> Date<Arc<A>> {
365365
Date::from_raw(self.inner, Arc::new(self.calendar))
366366
}
367367

368368
/// Wrap the calendar type in `Ref<T>`
369369
///
370370
/// Useful for converting a `&Date<C>` into an equivalent `Date<D>` without cloning
371371
/// the calendar.
372-
pub fn wrap_calendar_in_ref(&self) -> Date<Ref<A>> {
372+
pub fn as_borrowed(&self) -> Date<Ref<A>> {
373373
Date::from_raw(self.inner, Ref(&self.calendar))
374374
}
375375
}

ffi/capi/src/date.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub mod ffi {
7474

7575
#[diplomat::rust_link(icu::calendar::Date::to_any, FnInStruct)]
7676
pub fn to_any(&self) -> Box<Date> {
77-
Box::new(Date(self.0.to_any().wrap_calendar_in_arc()))
77+
Box::new(Date(self.0.to_any().into_atomic_ref_counted()))
7878
}
7979

8080
/// Returns this date's Rata Die

ffi/capi/src/date_formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ pub mod ffi {
639639
date: &Date,
640640
write: &mut diplomat_runtime::DiplomatWrite,
641641
) -> Result<(), DateTimeMismatchedCalendarError> {
642-
let date = date.0.wrap_calendar_in_ref();
642+
let date = date.0.as_borrowed();
643643
let value = date;
644644
let _infallible = self.0.format_same_calendar(&value)?.write_to(write);
645645
Ok(())

ffi/capi/src/date_time_formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ pub mod ffi {
510510
time: &Time,
511511
write: &mut diplomat_runtime::DiplomatWrite,
512512
) -> Result<(), DateTimeMismatchedCalendarError> {
513-
let date = date.0.wrap_calendar_in_ref();
513+
let date = date.0.as_borrowed();
514514
let value = icu_time::DateTime {
515515
date,
516516
time: time.0,

tools/make/codegen/templates/datetime_formatter.rs.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub mod ffi {
187187
{%- endif %}
188188
write: &mut diplomat_runtime::DiplomatWrite,
189189
) -> Result<(), DateTimeMismatchedCalendarError> {
190-
let date = date.0.wrap_calendar_in_ref();
190+
let date = date.0.as_borrowed();
191191
{%- if flavor.has_time() %}
192192
let value = icu_time::DateTime {
193193
date,

tools/make/diplomat-coverage/src/allowlist.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ lazy_static::lazy_static! {
341341
"icu::datetime::DateTimeFormatter::cast_into_fset",
342342
"icu::datetime::FixedCalendarDateTimeFormatter::cast_into_fset",
343343
// TODO-2.0: needs investigation
344-
"icu::calendar::Date::wrap_calendar_in_rc",
345-
"icu::calendar::Date::wrap_calendar_in_arc",
346-
"icu::calendar::Date::wrap_calendar_in_ref",
344+
"icu::calendar::Date::into_ref_counted",
345+
"icu::calendar::Date::into_atomic_ref_counted",
346+
"icu::calendar::Date::as_borrowed",
347347

348348
// Generic type, primarily exists for use by ICU4X data struct internals.
349349
"icu::plurals::PluralElements",

0 commit comments

Comments
 (0)