#[non_exhaustive]pub enum AnnotationKind {
Primary,
Context,
Visible,
}
Expand description
The type of Annotation
being applied to a Snippet
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Primary
For showing the source that the Group’s Title references
For Title
-less groups, see Group::with_level
Context
Additional context to better understand the Primary
Annotation
See also Renderer::context
.
Visible
Prevents the annotated text from getting folded
By default, Snippet
s will fold (remove) lines
that do not contain any annotations. Visible
makes
it possible to selectively prevent this behavior for specific text,
allowing context to be preserved without adding any annotation
characters.
§Example
use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
fn main() {
let source = r#"struct S {
field1: usize,
field2: usize,
field3: usize,
field4: usize,
fn foo() {},
field6: usize,
}
"#;
let report = &[Group::with_title(
Level::ERROR.primary_title("functions are not allowed in struct definitions"),
)
.element(
Snippet::source(source)
.path("$DIR/struct_name_as_context.rs")
.annotation(AnnotationKind::Primary.span(91..102))
.annotation(AnnotationKind::Visible.span(0..8)),
)
.element(
Level::HELP.message("unlike in C++, Java, and C#, functions are declared in `impl` blocks"),
)];
let renderer = Renderer::styled();
anstream::println!("{}", renderer.render(report));
}
Implementations§
Trait Implementations§
Source§impl Clone for AnnotationKind
impl Clone for AnnotationKind
Source§fn clone(&self) -> AnnotationKind
fn clone(&self) -> AnnotationKind
Returns a duplicate 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 Debug for AnnotationKind
impl Debug for AnnotationKind
Source§impl Ord for AnnotationKind
impl Ord for AnnotationKind
Source§fn cmp(&self, other: &AnnotationKind) -> Ordering
fn cmp(&self, other: &AnnotationKind) -> 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 PartialEq for AnnotationKind
impl PartialEq for AnnotationKind
Source§impl PartialOrd for AnnotationKind
impl PartialOrd for AnnotationKind
impl Copy for AnnotationKind
impl Eq for AnnotationKind
impl StructuralPartialEq for AnnotationKind
Auto Trait Implementations§
impl Freeze for AnnotationKind
impl RefUnwindSafe for AnnotationKind
impl Send for AnnotationKind
impl Sync for AnnotationKind
impl Unpin for AnnotationKind
impl UnwindSafe for AnnotationKind
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