From 1f864f8031a6bfd057d565b5bbd9945011d85f1e Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Sun, 14 Apr 2024 11:30:48 -0400 Subject: [PATCH] Demonstrate passing a hashmap to a procmacro function. #1774 said it doesn't work but it does if you pass the correct type --- fixtures/proc-macro/src/lib.rs | 1 - fixtures/proc-macro/tests/bindings/test_proc_macro.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fixtures/proc-macro/src/lib.rs b/fixtures/proc-macro/src/lib.rs index 74480f3aa7..8fbcac65a1 100644 --- a/fixtures/proc-macro/src/lib.rs +++ b/fixtures/proc-macro/src/lib.rs @@ -144,7 +144,6 @@ fn make_hashmap(k: i8, v: u64) -> HashMap { HashMap::from([(k, v)]) } -// XXX - fails to call this from python - https://github.com/mozilla/uniffi-rs/issues/1774 #[uniffi::export] fn return_hashmap(h: HashMap) -> HashMap { h diff --git a/fixtures/proc-macro/tests/bindings/test_proc_macro.py b/fixtures/proc-macro/tests/bindings/test_proc_macro.py index b2a317bef6..c8e8b275e8 100644 --- a/fixtures/proc-macro/tests/bindings/test_proc_macro.py +++ b/fixtures/proc-macro/tests/bindings/test_proc_macro.py @@ -42,9 +42,8 @@ assert(make_record_with_bytes().some_bytes == bytes([0, 1, 2, 3, 4])) assert(make_hashmap(1, 2) == {1: 2}) -# fails with AttributeError!? - https://github.com/mozilla/uniffi-rs/issues/1774 -# d = {1, 2} -# assert(return_hashmap(d) == d) +d = {1: 2} +assert(return_hashmap(d) == d) assert(join(["a", "b", "c"], ":") == "a:b:c")