Skip to content

Commit

Permalink
style(arena): reformat the code
Browse files Browse the repository at this point in the history
Imported `core::mem` and formatted code using rustfmt
  • Loading branch information
alexmozaidze authored and saschagrunert committed Jun 25, 2024
1 parent 83be098 commit b228a89
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use alloc::vec::Vec;

#[cfg(not(feature = "std"))]
use core::{
mem,
num::NonZeroUsize,
ops::{Index, IndexMut},
};
Expand All @@ -17,6 +18,7 @@ use serde::{Deserialize, Serialize};

#[cfg(feature = "std")]
use std::{
mem,
num::NonZeroUsize,
ops::{Index, IndexMut},
};
Expand Down Expand Up @@ -86,12 +88,13 @@ impl<T> Arena<T> {
return None;
}

let node_index = (p as usize - nodes_range.start as usize) / core::mem::size_of::<Node<T>>();
let Some(node_id) = NonZeroUsize::new(node_index.wrapping_add(1)) else {
return None;
};
let node_index = (p as usize - nodes_range.start as usize) / mem::size_of::<Node<T>>();
let node_id = NonZeroUsize::new(node_index.wrapping_add(1))?;

Some(NodeId::from_non_zero_usize(node_id, self.nodes[node_index].stamp))
Some(NodeId::from_non_zero_usize(
node_id,
self.nodes[node_index].stamp,
))
}

/// Retrieves the `NodeId` corresponding to the `Node` at `index` in the `Arena`, if it exists.
Expand Down

0 comments on commit b228a89

Please sign in to comment.