git.delta.rocks / jrsonnet / refs/commits / c678cf8e698f

difftreelog

source

crates/jrsonnet-rowan-parser/src/token_set.rs750 Bsourcehistory
1use crate::SyntaxKind;23#[derive(Clone, Copy, Default)]4pub struct SyntaxKindSet(u64);56impl SyntaxKindSet {7	pub const EMPTY: Self = Self(0);8	pub const ALL: Self = Self(u64::MAX);910	pub const fn new(kinds: &[SyntaxKind]) -> SyntaxKindSet {11		let mut res = 0u64;12		let mut i = 0;13		while i < kinds.len() {14			res |= mask(kinds[i]);15			i += 116		}17		SyntaxKindSet(res)18	}1920	pub const fn union(self, other: SyntaxKindSet) -> SyntaxKindSet {21		SyntaxKindSet(self.0 | other.0)22	}2324	pub const fn contains(&self, kind: SyntaxKind) -> bool {25		self.0 & mask(kind) != 026	}27}2829const fn mask(kind: SyntaxKind) -> u64 {30	1u64 << (kind as usize)31}3233#[macro_export]34macro_rules! TS {35	($($tt:tt)*) => {36		SyntaxKindSet::new(&[37			$(38				T![$tt]39			),*40		])41	};42}