/ src / compiler_types.rs
compiler_types.rs
 1  //! A collection of data types used throughout the compiler.
 2  
 3  /// A sorted map.
 4  pub type Map<K, V> = std::collections::BTreeMap<K, V>;
 5  
 6  /// A sorted set.
 7  pub type Set<K> = std::collections::BTreeSet<K>;
 8  
 9  /// An owned string type that is cheap to clone.
10  pub type Str = std::rc::Rc<str>;
11  
12  /// A source span, a single subsection of a source file corresponding to an item.
13  pub type Span = core::ops::Range<usize>;
14  
15  /// A string that carries its own span.
16  pub type Name = Spanned<Str>;
17  
18  /// A wrapper type for associating an item with a source span. This type is generally aliased by an item type `Foo` wrapping around a `FooKind`.
19  #[derive(Clone, Debug, PartialEq, Eq)]
20  pub struct Spanned<T> {
21      /// The inner value.
22      pub kind: T,
23      /// The span corresponding to the inner value.
24      pub span: Span,
25  }