Skip to content

Commit

Permalink
Adjusted examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostie314159 committed Aug 11, 2024
1 parent 54dc3e9 commit 8a15bd4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/initialised.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use atomic_pool::{pool, Box};
use std::mem;

pool!(TestPool: [u32; 3], [0u32; 3]);

fn main() {
let mut buffer = unsafe { Box::<TestPool>::new_potentially_uninit() }.unwrap();
println!("Allocated new buffer, with contents: {:#x}", *buffer);

*buffer = 0xf00dbabeu32;

let _buffer_2 = unsafe { Box::<TestPool>::new_potentially_uninit() }.unwrap();
let _buffer_3 = unsafe { Box::<TestPool>::new_potentially_uninit() }.unwrap();

mem::drop(buffer);
println!("Dropped buffer.");

let reallocated_buffer = unsafe { Box::<TestPool>::new_potentially_uninit() }.unwrap();
println!(
"Reallocated buffer, with contents: 0x{:#x}",
*reallocated_buffer
);
}
1 change: 1 addition & 0 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unused)]
use std::mem;

use atomic_pool::{pool, Box};
Expand Down

0 comments on commit 8a15bd4

Please sign in to comment.