[red-knot] Extract red_knot_python_semantic crate (#11926)

This commit is contained in:
Micha Reiser 2024-06-20 12:24:24 +01:00 committed by GitHub
parent ed948eaefb
commit 2dfbf118d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 125 additions and 94 deletions

View file

@ -0,0 +1,24 @@
use ruff_python_ast::{AnyNodeRef, NodeKind};
use ruff_text_size::{Ranged, TextRange};
/// Compact key for a node for use in a hash map.
///
/// Compares two nodes by their kind and text range.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub(super) struct NodeKey {
kind: NodeKind,
range: TextRange,
}
impl NodeKey {
pub(super) fn from_node<'a, N>(node: N) -> Self
where
N: Into<AnyNodeRef<'a>>,
{
let node = node.into();
NodeKey {
kind: node.kind(),
range: node.range(),
}
}
}