pub struct NamedSource<S: SourceCode + 'static> { /* private fields */ }
Expand description
Utility struct for when you have a regular SourceCode
type that doesn’t
implement name
. For example String
. Or if you want to override the
name
returned by the SourceCode
.
Implementations§
Source§impl<S: SourceCode + 'static> NamedSource<S>
impl<S: SourceCode + 'static> NamedSource<S>
Sourcepub fn new(name: impl AsRef<str>, source: S) -> Self
pub fn new(name: impl AsRef<str>, source: S) -> Self
Create a new NamedSource
using a regular SourceCode
and giving
its returned SpanContents
a name.
Sourcepub fn inner(&self) -> &S
pub fn inner(&self) -> &S
Returns a reference the inner SourceCode
type for this
NamedSource
.
Sourcepub fn with_language(self, language: impl Into<String>) -> Self
pub fn with_language(self, language: impl Into<String>) -> Self
Sets the language
for this source code.
Trait Implementations§
Source§impl<S: Clone + SourceCode + 'static> Clone for NamedSource<S>
impl<S: Clone + SourceCode + 'static> Clone for NamedSource<S>
Source§fn clone(&self) -> NamedSource<S>
fn clone(&self) -> NamedSource<S>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<S: SourceCode> Debug for NamedSource<S>
impl<S: SourceCode> Debug for NamedSource<S>
Source§impl<S: Hash + SourceCode + 'static> Hash for NamedSource<S>
impl<S: Hash + SourceCode + 'static> Hash for NamedSource<S>
Source§impl<S: Ord + SourceCode + 'static> Ord for NamedSource<S>
impl<S: Ord + SourceCode + 'static> Ord for NamedSource<S>
Source§fn cmp(&self, other: &NamedSource<S>) -> Ordering
fn cmp(&self, other: &NamedSource<S>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<S: PartialEq + SourceCode + 'static> PartialEq for NamedSource<S>
impl<S: PartialEq + SourceCode + 'static> PartialEq for NamedSource<S>
Source§impl<S: PartialOrd + SourceCode + 'static> PartialOrd for NamedSource<S>
impl<S: PartialOrd + SourceCode + 'static> PartialOrd for NamedSource<S>
Source§impl<S: SourceCode + 'static> SourceCode for NamedSource<S>
impl<S: SourceCode + 'static> SourceCode for NamedSource<S>
Source§fn read_span<'a>(
&'a self,
span: &SourceSpan,
context_lines_before: usize,
context_lines_after: usize,
) -> Result<Box<dyn SpanContents<'a> + 'a>, MietteError>
fn read_span<'a>( &'a self, span: &SourceSpan, context_lines_before: usize, context_lines_after: usize, ) -> Result<Box<dyn SpanContents<'a> + 'a>, MietteError>
Read the bytes for a specific span from this
SourceCode
, keeping a
certain number of lines before and after the span as context.impl<S: Eq + SourceCode + 'static> Eq for NamedSource<S>
impl<S: SourceCode + 'static> StructuralPartialEq for NamedSource<S>
Auto Trait Implementations§
impl<S> Freeze for NamedSource<S>where
S: Freeze,
impl<S> RefUnwindSafe for NamedSource<S>where
S: RefUnwindSafe,
impl<S> Send for NamedSource<S>
impl<S> Sync for NamedSource<S>
impl<S> Unpin for NamedSource<S>where
S: Unpin,
impl<S> UnwindSafe for NamedSource<S>where
S: UnwindSafe,
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