MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / structref_fields

Function structref_fields

tests/all/structs.rs:859–877  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

857
858#[test]
859fn structref_fields() -> Result<()> {
860 let mut store = gc_store()?;
861 let struct_ty = StructType::new(
862 store.engine(),
863 [
864 FieldType::new(Mutability::Const, ValType::I32.into()),
865 FieldType::new(Mutability::Const, ValType::I64.into()),
866 ],
867 )?;
868 let pre = StructRefPre::new(&mut store, struct_ty);
869 let s = StructRef::new(&mut store, &pre, &[Val::I32(11), Val::I64(22)])?;
870
871 let fields: Vec<Val> = s.fields(&mut store)?.collect();
872 assert_eq!(fields.len(), 2);
873 assert_eq!(fields[0].unwrap_i32(), 11);
874 assert_eq!(fields[1].unwrap_i64(), 22);
875
876 Ok(())
877}
878
879#[wasmtime_test(wasm_features(function_references, gc))]
880#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 6

gc_storeFunction · 0.85
OkFunction · 0.85
collectMethod · 0.80
newFunction · 0.50
engineMethod · 0.45
fieldsMethod · 0.45

Tested by

no test coverage detected