Skip to content

Commit

Permalink
Add PhantomData databake impl (#4663)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Mar 7, 2024
1 parent 6af2333 commit 74f6687
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
- Add Keviyah/Four Gates based optimized calculations module for the Hebrew calendar. (https://github.com/unicode-org/icu4x/pull/4504)
- Expose `Hebrew` as a unit struct, add `Date::try_new_hebrew_date()`, `DateTime::try_new_hebrew_datetime()`. (https://github.com/unicode-org/icu4x/pulls/4532)
- Deprecate `Hebrew::new_always_precomputing()`, `Date::try_new_hebrew_date_with_calendar()`, `DateTime::try_new_hebrew_datetime_with_calendar()`. The new implementation of the Hebrew calendar is faster and we do not need APIs for precomputation. (https://github.com/unicode-org/icu4x/pulls/4532)
- `databake`
- Add `impl Bake for PhantomData<T>` (https://github.com/unicode-org/icu4x/pull/4663)
- `litemap`
- Add `impl IntoIterator for LiteMap` by splitting `StoreIterableMut` trait (https://github.com/unicode-org/icu4x/pull/4359)
- `yoke`
Expand Down
18 changes: 18 additions & 0 deletions utils/databake/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use std::marker::PhantomData;

use super::*;

macro_rules! literal {
Expand Down Expand Up @@ -255,3 +257,19 @@ fn tuple() {
const: (0u8, 0i8)
);
}

impl<T> Bake for PhantomData<T> {
fn bake(&self, _ctx: &CrateEnv) -> TokenStream {
quote! {
::core::marker::PhantomData
}
}
}

#[test]
fn phantom_data() {
test_bake!(
PhantomData<usize>,
const: ::core::marker::PhantomData
);
}

0 comments on commit 74f6687

Please sign in to comment.