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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)