pub struct SourceStore { /* private fields */ }Expand description
Source ownership for single parse, batch parse, diagnostics, and Phase 2 snapshot roots.
Implementations§
Source§impl SourceStore
impl SourceStore
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn files(&self) -> &[SourceFile]
Sourcepub fn add(&mut self, input: SourceFileInput<'_>) -> SourceId
pub fn add(&mut self, input: SourceFileInput<'_>) -> SourceId
Register a source file. Panics if the source is larger than
u32::MAX bytes — use SourceStore::try_add for the fallible variant.
pub fn try_add( &mut self, input: SourceFileInput<'_>, ) -> Result<SourceId, SourceStoreError>
pub fn get(&self, id: SourceId) -> Option<&SourceFile>
Sourcepub fn slice(&self, span: Span) -> &str
pub fn slice(&self, span: Span) -> &str
Resolve a byte span in the most recently relevant file. Callers that
know which source the span belongs to should use Self::slice_in.
pub fn slice_in(&self, source: SourceId, span: Span) -> &str
Sourcepub fn location(&self, source: SourceId, span: Span) -> SourceLocation
pub fn location(&self, source: SourceId, span: Span) -> SourceLocation
Resolve a 1-based line/column for the start of span inside source.
Triggers lazy line-index initialisation on the first call per file.
Trait Implementations§
Source§impl Clone for SourceStore
impl Clone for SourceStore
Source§fn clone(&self) -> SourceStore
fn clone(&self) -> SourceStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourceStore
impl Debug for SourceStore
Source§impl Default for SourceStore
impl Default for SourceStore
Source§fn default() -> SourceStore
fn default() -> SourceStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SourceStore
impl RefUnwindSafe for SourceStore
impl Send for SourceStore
impl Sync for SourceStore
impl Unpin for SourceStore
impl UnsafeUnpin for SourceStore
impl UnwindSafe for SourceStore
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