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

Function struct_fields_non_empty

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

Source from the content-addressed store, hash-verified

329
330#[test]
331fn struct_fields_non_empty() -> Result<()> {
332 let mut store = gc_store()?;
333 let struct_ty = StructType::new(
334 store.engine(),
335 [
336 FieldType::new(Mutability::Const, StorageType::I8),
337 FieldType::new(Mutability::Var, StorageType::ValType(ValType::ANYREF)),
338 ],
339 )?;
340 let pre = StructRefPre::new(&mut store, struct_ty.clone());
341 let s = StructRef::new(&mut store, &pre, &[Val::I32(36), Val::null_any_ref()])?;
342 let mut fields = s.fields(&mut store)?;
343 assert_eq!(fields.len(), 2);
344 assert_eq!(fields.next().unwrap().unwrap_i32(), 36);
345 assert!(fields.next().unwrap().unwrap_any_ref().is_none());
346 assert!(fields.next().is_none());
347 Ok(())
348}
349
350#[test]
351fn struct_fields_unrooted() -> Result<()> {

Callers

nothing calls this directly

Calls 7

gc_storeFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
ValTypeEnum · 0.50
engineMethod · 0.45
cloneMethod · 0.45
fieldsMethod · 0.45

Tested by

no test coverage detected