Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into frankdavid/typekey
Browse files Browse the repository at this point in the history
# Conflicts:
#	Changelog.md
  • Loading branch information
frankdavid committed Jan 17, 2025
2 parents 8140e7a + d5a5127 commit 67a1964
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @dfinity/languages
* @dfinity/dx
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
* In `Type::Var(var)` `var` now has type `TypeKey` instead of `String`. Calling `var.as_str()` returns `&str` and `var.to_string()` returns a `String`. The string representation of indexed variables remains `table{index}` to maintain compatibility with previous versions.
* `TypeEnv` now contains a `HashMap` instead of `BTreeMap`. Code that relied on the iteration order of the map (e.g. `env.0.iter()`) should make use of the newly added `TypeEnv::to_sorted_iter()` method which returns types sorted by their keys.

## 2025-01-15

### Candid 0.10.12

* Implement `CandidType` for `std::marker::PhantomData`.

## 2024-12-10

### Candid 0.10.11
Expand Down
2 changes: 1 addition & 1 deletion rust/candid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candid"
version = "0.10.11"
version = "0.10.12"
edition = "2021"
rust-version.workspace = true
authors = ["DFINITY Team"]
Expand Down
16 changes: 16 additions & 0 deletions rust/candid/src/types/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,22 @@ where
}
}

impl<T> CandidType for std::marker::PhantomData<T>
where
T: CandidType,
{
fn _ty() -> Type {
T::ty()
}
fn idl_serialize<S>(&self, _: S) -> Result<(), S::Error>
where
S: Serializer,
{
use serde::ser::Error;
Err(S::Error::custom("`PhantomData` cannot be serialized"))
}
}

macro_rules! tuple_impls {
($($len:expr => ($($n:tt $name:ident)+))+) => {
$(
Expand Down
4 changes: 4 additions & 0 deletions rust/candid/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ fn test_primitive() {
get_type(&[0, 1, 2, 3]),
TypeInner::Vec(TypeInner::Int32.into()).into()
);
assert_eq!(
get_type(&std::marker::PhantomData::<u32>),
TypeInner::Nat32.into()
);
}

#[test]
Expand Down
5 changes: 5 additions & 0 deletions tools/didc-js/wasm-package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ log = "0.4"
getrandom = { version = "0.2", features = ["js"] }
serde-wasm-bindgen = "0.5"
js-sys = "0.3"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(wasm_bindgen_unstable_test_coverage)',
] }

0 comments on commit 67a1964

Please sign in to comment.