Skip to content

Commit

Permalink
Fix the example linked list possibly dropping an uninitalized element
Browse files Browse the repository at this point in the history
It even says it in the safety comment... smh my head.
  • Loading branch information
marc0246 committed Mar 21, 2024
1 parent a9b2a42 commit 675bd8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use core::{
///
/// // SAFETY: `SlabAllocator::allocate` gives out pointers that are valid for writes (but
/// // **not** for reads).
/// unsafe { *node.as_ptr() = Node::new(value) };
/// unsafe { ptr::write(node.as_ptr(), Node::new(value)) };
///
/// if let Some(tail) = self.tail {
/// unsafe { (*tail.as_ptr()).next = Some(node) };
Expand Down

0 comments on commit 675bd8b

Please sign in to comment.