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

Function truncate

cranelift/entity/src/list.rs:890–908  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

888
889 #[test]
890 fn truncate() {
891 let pool = &mut ListPool::<Inst>::new();
892
893 let i1 = Inst::new(1);
894 let i2 = Inst::new(2);
895 let i3 = Inst::new(3);
896 let i4 = Inst::new(4);
897
898 let mut list = EntityList::from_slice(&[i1, i2, i3, i4, i1, i2, i3, i4], pool);
899 assert_eq!(list.as_slice(pool), &[i1, i2, i3, i4, i1, i2, i3, i4]);
900 list.truncate(6, pool);
901 assert_eq!(list.as_slice(pool), &[i1, i2, i3, i4, i1, i2]);
902 list.truncate(9, pool);
903 assert_eq!(list.as_slice(pool), &[i1, i2, i3, i4, i1, i2]);
904 list.truncate(2, pool);
905 assert_eq!(list.as_slice(pool), &[i1, i2]);
906 list.truncate(0, pool);
907 assert!(list.is_empty());
908 }
909
910 #[test]
911 fn copy_from() {

Callers

nothing calls this directly

Calls 3

from_sliceFunction · 0.85
newFunction · 0.50
truncateMethod · 0.45

Tested by

no test coverage detected