INNER CODE UNIT · Rust

collect_into_alloc_vec_fills_the_whole_buffer

binius-zk/binius64 · crates/compute/src/lib.rs:280

	fn collect_into_alloc_vec_fills_the_whole_buffer() {
		// The pool rounds its blocks up, so 1000 items draw a buffer with spare slots past them.
		// Those slots must stay outside the collected length.
		let pool = BufferPool::new();
		let squares = (0..1000usize).into_par_iter().map(|i| (i * i) as u64);
		let buffer = squares.collect_into_alloc_vec(&&pool);
		assert_eq!(buffer.len(), 1000);
		assert!(
			buffer
				.iter()
				.enumerate()
				.all(|(i, &sq)| sq == (i * i) as u64)
		);
	}

	#[test]
	fn vec_truncates_through_buffer_data() {
		let mut buffer = vec![1u64, 2, 3, 4];

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…