From fb4e343bc5185a5436b98c6ef2f924d1ff5f7318 Mon Sep 17 00:00:00 2001 From: Xiaolong Fu <522023330025@smail.nju.edu.cn> Date: Thu, 27 Nov 2025 14:20:25 +0800 Subject: [PATCH] public accessor method for NodeId --- src/node/node.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/node/node.rs b/src/node/node.rs index c27608b..81394c0 100644 --- a/src/node/node.rs +++ b/src/node/node.rs @@ -61,6 +61,19 @@ pub trait Node: Send + Sync { #[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Ord, PartialOrd)] pub struct NodeId(pub(crate) usize); +impl NodeId { + /// Return the numeric identifier wrapped by this `NodeId`. + pub fn as_usize(&self) -> usize { + self.0 + } +} + +impl From for usize { + fn from(value: NodeId) -> Self { + value.0 + } +} + pub type NodeName = String; /// [NodeTable]: a mapping from [Node]'s name to [NodeId].