ty_python_core/
node_key.rs1use ruff_python_ast::{HasNodeIndex, NodeIndex};
2
3use crate::ast_node_ref::AstNodeRef;
4
5#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, get_size2::GetSize)]
7pub struct NodeKey(NodeIndex);
8
9impl NodeKey {
10 pub fn index(self) -> NodeIndex {
12 self.0
13 }
14
15 pub fn from_node<N>(node: N) -> Self
16 where
17 N: HasNodeIndex,
18 {
19 NodeKey(node.node_index().load())
20 }
21
22 pub fn from_node_ref<T>(node_ref: &AstNodeRef<T>) -> Self {
23 NodeKey(node_ref.index())
24 }
25}