MCPcopy Create free account
hub / github.com/hashintel/hash / map_repeat

Function map_repeat

libs/@local/hashql/core/src/intern/beef.rs:708–726  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

706 #[test]
707 #[expect(clippy::integer_division_remainder_used)]
708 fn map_repeat() {
709 let heap = Heap::new();
710 let interner = InternSet::new(&heap);
711 let original = interner.intern_slice(&[1, 2, 3, 4, 5]);
712
713 let mut beef = Beef::new(original);
714
715 // First modification
716 beef.map(|x| if x % 2 == 0 { x * 2 } else { x });
717 assert_eq!(beef.as_slice(), &[1, 4, 3, 8, 5]);
718
719 // Second modification
720 beef.map(|x| x + 1);
721 assert_eq!(beef.as_slice(), &[2, 5, 4, 9, 6]);
722
723 // Result should be interned with all modifications applied
724 let result = beef.finish(&interner);
725 assert_eq!(result.as_ref(), &[2, 5, 4, 9, 6]);
726 }
727
728 #[test]
729 fn map_edge_cases() {

Callers

nothing calls this directly

Calls 3

intern_sliceMethod · 0.80
mapMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected