Skip to content

Commit

Permalink
chore(core): Rename to {MastNodeId,DecoratorId}::new_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Oct 25, 2024
1 parent f09d7f9 commit f5a7327
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/src/mast/merger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl MastForestMerger {
};

decorator_id_remapping
.insert(DecoratorId::new_unsafe(merging_id as u32), new_decorator_id);
.insert(DecoratorId::new_unchecked(merging_id as u32), new_decorator_id);
}

self.decorator_id_mappings.push(decorator_id_remapping);
Expand Down
4 changes: 2 additions & 2 deletions core/src/mast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl MastNodeId {
}

/// Returns a new [`MastNodeId`] from the given `value` without checking its validity.
pub(crate) fn new_unsafe(value: u32) -> Self {
pub(crate) fn new_unchecked(value: u32) -> Self {
Self(value)
}

Expand Down Expand Up @@ -599,7 +599,7 @@ impl DecoratorId {
}

/// Creates a new [`DecoratorId`] without checking its validity.
pub(crate) fn new_unsafe(value: u32) -> Self {
pub(crate) fn new_unchecked(value: u32) -> Self {
Self(value)
}

Expand Down
16 changes: 8 additions & 8 deletions core/src/mast/multi_forest_node_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'forest> MultiMastForestNodeIter<'forest> {
for (node_idx, node) in forest.nodes().iter().enumerate() {
// SAFETY: The passed id comes from the iterator over the nodes, so we never exceed
// the forest's number of nodes.
let node_id = MastNodeId::new_unsafe(node_idx as u32);
let node_id = MastNodeId::new_unchecked(node_idx as u32);
if !node.is_external() {
non_external_nodes.insert(node.digest(), (forest_idx, node_id));
}
Expand Down Expand Up @@ -419,43 +419,43 @@ mod tests {
nodes[0],
MultiMastForestIteratorItem::Node {
forest_idx: 1,
node_id: MastNodeId::new_unsafe(2)
node_id: MastNodeId::new_unchecked(2)
}
);
// The external node replaced by the block foo from forest B.
assert_eq!(
nodes[1],
MultiMastForestIteratorItem::ExternalNodeReplacement {
replacement_forest_idx: 1,
replacement_mast_node_id: MastNodeId::new_unsafe(2),
replacement_mast_node_id: MastNodeId::new_unchecked(2),
replaced_forest_idx: 0,
replaced_mast_node_id: MastNodeId::new_unsafe(0)
replaced_mast_node_id: MastNodeId::new_unchecked(0)
}
);
// The call from forest A.
assert_eq!(
nodes[2],
MultiMastForestIteratorItem::Node {
forest_idx: 0,
node_id: MastNodeId::new_unsafe(1)
node_id: MastNodeId::new_unchecked(1)
}
);
// The replacement for the external node that is replaced by the Call in forest A.
assert_eq!(
nodes[3],
MultiMastForestIteratorItem::ExternalNodeReplacement {
replacement_forest_idx: 0,
replacement_mast_node_id: MastNodeId::new_unsafe(1),
replacement_mast_node_id: MastNodeId::new_unchecked(1),
replaced_forest_idx: 1,
replaced_mast_node_id: MastNodeId::new_unsafe(0)
replaced_mast_node_id: MastNodeId::new_unchecked(0)
}
);
// The call from forest B.
assert_eq!(
nodes[4],
MultiMastForestIteratorItem::Node {
forest_idx: 1,
node_id: MastNodeId::new_unsafe(1)
node_id: MastNodeId::new_unchecked(1)
}
);
}
Expand Down

0 comments on commit f5a7327

Please sign in to comment.