tamer: ir::xir (newtype_symbol!): Remove for now
This does not belong here and was more of a POC at the time. It can be added later on when I have the time; I have to move on.main
parent
f65ec818ab
commit
bc5091d2a7
|
@ -72,45 +72,18 @@ macro_rules! qname_const {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Move into crate::sym if this is staying around.
|
||||
macro_rules! newtype_symbol {
|
||||
{$($(#[$meta:meta])* pub struct $name:ident;)*} => {
|
||||
$(
|
||||
$(#[$meta])*
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct $name(SymbolId);
|
||||
|
||||
impl Deref for $name {
|
||||
type Target = SymbolId;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<SymbolId> for $name {
|
||||
fn eq(&self, other: &SymbolId) -> bool {
|
||||
self.0 == *other
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Derive macro instead?
|
||||
newtype_symbol! {
|
||||
/// XML Name minus `":"`.
|
||||
///
|
||||
/// The intent is to check a string for validity _before_ interning;
|
||||
/// otherwise,
|
||||
/// the string would have to be first retrieved from the intern pool
|
||||
/// for comparison,
|
||||
/// which is not an operation we want to do implicitly.
|
||||
/// Those methods will be created as they are needed.
|
||||
///
|
||||
/// See <https://www.w3.org/TR/REC-xml-names/#NT-NCName>.
|
||||
pub struct NCName;
|
||||
}
|
||||
/// XML Name minus `":"`.
|
||||
///
|
||||
/// The intent is to check a string for validity _before_ interning;
|
||||
/// otherwise,
|
||||
/// the string would have to be first retrieved from the intern pool
|
||||
/// for comparison,
|
||||
/// which is not an operation we want to do implicitly.
|
||||
/// Those methods will be created as they are needed.
|
||||
///
|
||||
/// See <https://www.w3.org/TR/REC-xml-names/#NT-NCName>.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct NCName(SymbolId);
|
||||
|
||||
impl NCName {
|
||||
/// Create a new NCName from a symbol without validating that the symbol
|
||||
|
@ -127,6 +100,20 @@ impl NCName {
|
|||
}
|
||||
}
|
||||
|
||||
impl Deref for NCName {
|
||||
type Target = SymbolId;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<SymbolId> for NCName {
|
||||
fn eq(&self, other: &SymbolId) -> bool {
|
||||
self.0 == *other
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
/// Provided name contains a `':'`.
|
||||
|
|
Loading…
Reference in New Issue