pub struct Snippet<'a, T> { /* private fields */ }
Expand description
A source view Element
in a Group
If you do not have source available, see instead Origin
Snippet
s come in the following styles (T
):
- With
Annotation
s, seeSnippet::annotation
- With
Patch
s, seeSnippet::patch
Implementations§
Source§impl<'a, T: Clone> Snippet<'a, T>
impl<'a, T: Clone> Snippet<'a, T>
Sourcepub fn source(source: impl Into<Cow<'a, str>>) -> Self
pub fn source(source: impl Into<Cow<'a, str>>) -> Self
The source code to be rendered
Text passed to this function is considered “untrusted input”, as such all text is passed through a normalization function. Pre-styled text is not allowed to be passed to this function.
Sourcepub fn line_start(self, line_start: usize) -> Self
pub fn line_start(self, line_start: usize) -> Self
Sourcepub fn path(self, path: impl Into<OptionCow<'a>>) -> Self
pub fn path(self, path: impl Into<OptionCow<'a>>) -> Self
The location of the source
(e.g. a path)
Text passed to this function is considered “untrusted input”, as such all text is passed through a normalization function. Pre-styled text is not allowed to be passed to this function.
Sourcepub fn fold(self, fold: bool) -> Self
pub fn fold(self, fold: bool) -> Self
Control whether lines without Annotation
s are shown
The default is fold(true)
, collapsing uninteresting lines.
See AnnotationKind::Visible
to force specific spans to be shown.
Source§impl<'a> Snippet<'a, Annotation<'a>>
impl<'a> Snippet<'a, Annotation<'a>>
Sourcepub fn annotation(
self,
annotation: Annotation<'a>,
) -> Snippet<'a, Annotation<'a>>
pub fn annotation( self, annotation: Annotation<'a>, ) -> Snippet<'a, Annotation<'a>>
Highlight and describe a span of text within the source
Sourcepub fn annotations(
self,
annotation: impl IntoIterator<Item = Annotation<'a>>,
) -> Self
pub fn annotations( self, annotation: impl IntoIterator<Item = Annotation<'a>>, ) -> Self
Highlight and describe spans of text within the source