pub enum Context {
None,
Show {
line: String,
},
FullLine {
linenumber: usize,
line: String,
},
Line {
linenumber: usize,
line: String,
offset: usize,
length: usize,
},
Range {
start_linenumber: usize,
lines: Vec<String>,
offset: usize,
},
RangeHighlights {
start_linenumber: usize,
lines: Vec<String>,
highlights: Vec<(usize, usize, usize)>,
},
Multiple {
contexts: Vec<(Option<String>, Context)>,
},
}
Expand description
A struct to define the context of an error message
Variants§
None
When no context can be given
Show
When only a line (e.g. in a file) can be shown
FullLine
Fields
When a full line is faulty and no special position can be annotated
Line
Fields
When a special position can be annotated on a line.
|
104 | ATOM O N MET A 1 27.251 24.447 2.594 1.00 11.79 N
| ^^^^
<- -><-->
The first space (annotated by <-
, ->
) is the offset, in this case 7. The
second space is the length, in this case 4.
Range
Fields
To show multiple lines where an error occurred.
RangeHighlights
Fields
To show multiple lines where an error occurred.
Multiple
To show multiple contexts
Implementations§
source§impl Context
impl Context
sourcepub fn show(line: impl ToString) -> Context
pub fn show(line: impl ToString) -> Context
Creates a new context when only a line (eg filename) can be shown
sourcepub fn full_line(linenumber: usize, line: impl ToString) -> Context
pub fn full_line(linenumber: usize, line: impl ToString) -> Context
Creates a new context when a full line is faulty and no special position can be annotated
sourcepub fn line(
linenumber: usize,
line: impl ToString,
offset: usize,
length: usize
) -> Context
pub fn line( linenumber: usize, line: impl ToString, offset: usize, length: usize ) -> Context
Creates a new context when a special position can be annotated on a line
Trait Implementations§
source§impl PartialEq<Context> for Context
impl PartialEq<Context> for Context
impl Eq for Context
impl StructuralEq for Context
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.