Fix broken tests and docs

This commit is contained in:
Sosthène Guédon 2025-08-11 19:19:13 +02:00
parent b94d0b4526
commit a13946d523
4 changed files with 10 additions and 5 deletions

View File

@ -61,13 +61,13 @@ mod tests {
#[test]
#[should_panic]
fn buf_mut_advance_mut_out_of_bounds_view() {
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8>::new();
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8, u8>::new();
unsafe { vec.advance_mut(9) };
}
#[test]
fn buf_mut_remaining_mut_view() {
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8>::new();
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8, u8>::new();
assert_eq!(vec.remaining_mut(), 8);
vec.push(42).unwrap();
assert_eq!(vec.remaining_mut(), 7);
@ -75,7 +75,7 @@ mod tests {
#[test]
fn buf_mut_chunk_mut_view() {
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8>::new();
let vec: &mut VecView<u8, u8> = &mut Vec::<u8, 8, u8>::new();
assert_eq!(vec.chunk_mut().len(), 8);
unsafe { vec.advance_mut(1) };
assert_eq!(vec.chunk_mut().len(), 7);

View File

@ -3,6 +3,7 @@
//! # Example usage
//!
//! ```
//! use core::ptr::addr_of_mut;
//! use heapless::{arc_pool, pool::arc::{Arc, ArcBlock}};
//!
//! arc_pool!(MyArcPool: u128);
@ -45,6 +46,7 @@
//! to the `ArcPool`. This requires an intermediate `const` value as shown below:
//!
//! ```
//! use core::ptr::addr_of_mut;
//! use heapless::{arc_pool, pool::arc::ArcBlock};
//!
//! arc_pool!(MyArcPool: u128);
@ -54,7 +56,7 @@
//! let blocks: &'static mut [ArcBlock<u128>] = {
//! const BLOCK: ArcBlock<u128> = ArcBlock::new(); // <=
//! static mut BLOCKS: [ArcBlock<u128>; POOL_CAPACITY] = [BLOCK; POOL_CAPACITY];
//! unsafe { addr_of_mut!(BLOCK).as_mut().unwrap()S }
//! unsafe { addr_of_mut!(BLOCKS).as_mut().unwrap() }
//! };
//!
//! for block in blocks {

View File

@ -61,6 +61,7 @@
//! to the `BoxPool`. This requires an intermediate `const` value as shown below:
//!
//! ```
//! use core::ptr::addr_of_mut;
//! use heapless::{box_pool, pool::boxed::BoxBlock};
//!
//! box_pool!(MyBoxPool: u128);

View File

@ -3,6 +3,7 @@
//! # Example usage
//!
//! ```
//! use core::ptr::addr_of_mut;
//! use heapless::{object_pool, pool::object::{Object, ObjectBlock}};
//!
//! object_pool!(MyObjectPool: [u8; 128]);
@ -46,6 +47,7 @@
//! to the `ObjectPool`. This requires an intermediate `const` value as shown below:
//!
//! ```
//! use core::ptr::addr_of_mut;
//! use heapless::{object_pool, pool::object::ObjectBlock};
//!
//! object_pool!(MyObjectPool: [u8; 128]);
@ -55,7 +57,7 @@
//! let blocks: &'static mut [ObjectBlock<[u8; 128]>] = {
//! const BLOCK: ObjectBlock<[u8; 128]> = ObjectBlock::new([0; 128]); // <=
//! static mut BLOCKS: [ObjectBlock<[u8; 128]>; POOL_CAPACITY] = [BLOCK; POOL_CAPACITY];
//! unsafe { addr_of_mut!(BLOCK).as_mut().unwrap()S }
//! unsafe { addr_of_mut!(BLOCKS).as_mut().unwrap() }
//! };
//!
//! for block in blocks {