/// A case-sensitive set of strings, /// for use with [`Namer`][crate::proc::Namer] to avoid collisions with keywords and other reserved /// identifiers. /// /// This is currently implemented as a hash table. /// Future versions of Naga may change the implementation based on speed and code size /// considerations. #[derive(Clone, Debug, Default, Eq, PartialEq)] pubstruct KeywordSet(FastHashSet<&'static str>);
impl KeywordSet { /// Returns a new mutable empty set. pubfn new() -> Self { Self::default()
}
/// Returns a reference to the empty set. pubfn empty() -> &'static Self { static EMPTY: RacyLock<KeywordSet> = RacyLock::new(Default::default);
&EMPTY
}
/// Returns whether the set contains the given string. #[inline] pubfn contains(&self, identifier: &str) -> bool { self.0.contains(identifier)
}
}
/// Accepts double references so that `.extend(&["foo"])` works. impl<'a> Extend<&'a &'static str> for KeywordSet { fn extend<T: IntoIterator<Item = &'a &'static str>>(&'color:red'>mutself, iter: T) { self.extend(iter.into_iter().copied())
}
}
/// A case-insensitive, ASCII-only set of strings, /// for use with [`Namer`][crate::proc::Namer] to avoid collisions with keywords and other reserved /// identifiers. /// /// This is currently implemented as a hash table. /// Future versions of Naga may change the implementation based on speed and code size /// considerations. #[derive(Clone, Debug, Default, Eq, PartialEq)] pubstruct CaseInsensitiveKeywordSet(FastHashSet<AsciiUniCase<&'static str>>);
impl CaseInsensitiveKeywordSet { /// Returns a new mutable empty set. pubfn new() -> Self { Self::default()
}
/// Returns a reference to the empty set. pubfn empty() -> &'static Self { static EMPTY: RacyLock<CaseInsensitiveKeywordSet> = RacyLock::new(Default::default);
&EMPTY
}
/// Returns whether the set contains the given string, with comparison /// by [`str::eq_ignore_ascii_case()`]. #[inline] pubfn contains(&self, identifier: &str) -> bool { self.0.contains(&AsciiUniCase(identifier))
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.