pub struct SourceMap { /* private fields */ }Expand description
A collection of loaded source files indexed by both id and normalized name.
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn next_id(&self) -> SourceId
pub fn next_id(&self) -> SourceId
Returns the next identifier that would be assigned to a new file.
Sourcepub fn insert_file(&mut self, file: SourceFile) -> SourceId
pub fn insert_file(&mut self, file: SourceFile) -> SourceId
Inserts a fully constructed source file.
Sourcepub fn add_file(
&mut self,
name: impl Into<String>,
contents: impl Into<Vec<u8>>,
) -> SourceId
pub fn add_file( &mut self, name: impl Into<String>, contents: impl Into<Vec<u8>>, ) -> SourceId
Creates and inserts a new source file.
Sourcepub fn get(&self, id: SourceId) -> Option<&SourceFile>
pub fn get(&self, id: SourceId) -> Option<&SourceFile>
Returns the file for id.
Sourcepub fn get_by_name(&self, name: &str) -> Option<&SourceFile>
pub fn get_by_name(&self, name: &str) -> Option<&SourceFile>
Returns the file for name, using case-insensitive matching.
Sourcepub fn contains_name(&self, name: &str) -> bool
pub fn contains_name(&self, name: &str) -> bool
Returns true when a file with name has already been loaded.
Sourcepub fn iter(&self) -> impl Iterator<Item = &SourceFile>
pub fn iter(&self) -> impl Iterator<Item = &SourceFile>
Iterates over loaded source files in insertion order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SourceMap
impl<'de> Deserialize<'de> for SourceMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for SourceMap
impl StructuralPartialEq for SourceMap
Auto Trait Implementations§
impl Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnsafeUnpin for SourceMap
impl UnwindSafe for SourceMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.