pub struct Sources { /* private fields */ }Expand description
Registry of every source file in a compilation, indexed by FileId.
Implementations§
Source§impl Sources
impl Sources
pub fn new() -> Self
Sourcepub fn add(
&mut self,
path: impl Into<ModulePath>,
text: impl AsRef<str>,
) -> Result<FileId, SourceError>
pub fn add( &mut self, path: impl Into<ModulePath>, text: impl AsRef<str>, ) -> Result<FileId, SourceError>
Register a file and return its FileId.
Sourcepub fn add_package_module(
&mut self,
package: &str,
module: &str,
text: impl AsRef<str>,
) -> Result<FileId, SourceError>
pub fn add_package_module( &mut self, package: &str, module: &str, text: impl AsRef<str>, ) -> Result<FileId, SourceError>
Register a package module under the path its backtrace frames carry
([package_frame_path]), so they render with its source.
pub fn get(&self, id: FileId) -> Option<&SourceFile>
pub fn find_path(&self, path: &str) -> Option<(FileId, &SourceFile)>
Sourcepub fn single(
path: impl Into<ModulePath>,
text: impl AsRef<str>,
) -> Result<(Self, FileId), SourceError>
pub fn single( path: impl Into<ModulePath>, text: impl AsRef<str>, ) -> Result<(Self, FileId), SourceError>
Convenience for the single-file path: a registry with one entry plus its FileId.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sources
impl RefUnwindSafe for Sources
impl Send for Sources
impl Sync for Sources
impl Unpin for Sources
impl UnsafeUnpin for Sources
impl UnwindSafe for Sources
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