Wybxc opened issue #11813:
Feature
eqrefincludesstructref,arrayref, andi31ref, but currently only the first two can be directly cast toeqrefin the host language. Methods should be provided to createeqreffromi31refin the host language.Implementation
This should only require transmuting the internal value.
Alternatives
The current workaround is to convert to
AnyRefand then toEqRef.let value = 1i32; let i31 = I31::new_i32(value).unwrap(); let any_ref = AnyRef::from_i31(&mut store, i31); let eq_ref = value.unwrap_eqref(&mut store);
alexcrichton added the wasmtime:api label to Issue #11813.
alexcrichton added the wasm-proposal:gc label to Issue #11813.
fitzgen commented on issue #11813:
We can't transmute an
I31into aRooted<EqRef>, as they have different representations, but we could certainly create aEqRef::from_i31(&mut store, my_i31)constructor. It should be pretty much identical toAnyRef::from_i31.@Wybxc would you be up for sending a PR to implement this?
alexcrichton closed issue #11813:
Feature
eqrefincludesstructref,arrayref, andi31ref, but currently only the first two can be directly cast toeqrefin the host language. Methods should be provided to createeqreffromi31refin the host language.Implementation
This should only require transmuting the internal value.
Alternatives
The current workaround is to convert to
AnyRefand then toEqRef.let value = 1i32; let i31 = I31::new_i32(value).unwrap(); let any_ref = AnyRef::from_i31(&mut store, i31); let eq_ref = value.unwrap_eqref(&mut store);
Last updated: Dec 06 2025 at 06:05 UTC