forked from Orchid/orchid
Removed a copious amount of premature Rc-s
This commit is contained in:
@@ -2,24 +2,12 @@
|
||||
//!
|
||||
//! Can be used to deduplicate various structures for fast equality comparisons.
|
||||
//! The parser uses it to intern strings.
|
||||
mod display;
|
||||
mod monotype;
|
||||
mod multitype;
|
||||
mod token;
|
||||
mod traits;
|
||||
|
||||
pub use display::{DisplayBundle, InternedDisplay};
|
||||
pub use monotype::TypedInterner;
|
||||
pub use multitype::Interner;
|
||||
pub use token::Tok;
|
||||
|
||||
/// A symbol, nsname, nname or namespaced name is a sequence of namespaces
|
||||
/// and an identifier. The [Vec] can never be empty.
|
||||
///
|
||||
/// Throughout different stages of processing, these names can be
|
||||
///
|
||||
/// - local names to be prefixed with the current module
|
||||
/// - imported names starting with a segment
|
||||
/// - ending a single import or
|
||||
/// - defined in one of the glob imported modules
|
||||
/// - absolute names
|
||||
pub type Sym = Tok<Vec<Tok<String>>>;
|
||||
pub use traits::{DisplayBundle, InternedDisplay, InternedInto};
|
||||
|
||||
@@ -54,3 +54,18 @@ impl<'a, T: InternedDisplay + ?Sized> Display for DisplayBundle<'a, T> {
|
||||
self.data.fmt_i(f, self.interner)
|
||||
}
|
||||
}
|
||||
|
||||
/// Conversions that are possible in the presence of an interner
|
||||
///
|
||||
/// Essentially, this allows to define abstractions over interned and
|
||||
/// non-interned versions of a type and convert between them
|
||||
pub trait InternedInto<U> {
|
||||
/// Execute the conversion
|
||||
fn into_i(self, i: &Interner) -> U;
|
||||
}
|
||||
|
||||
impl<T: Into<U>, U> InternedInto<U> for T {
|
||||
fn into_i(self, _i: &Interner) -> U {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user