#[non_exhaustive]pub struct RuleViolation {
pub rule_name: &'static str,
pub message: String,
pub position: Option<usize>,
pub fragment: Option<String>,
}Expand description
A single rule violation with context.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.rule_name: &'static strWhich rule detected the violation.
message: StringHuman-readable description of the violation.
position: Option<usize>Byte offset in the input where the violation was found, if applicable.
fragment: Option<String>The problematic fragment, if applicable.
Implementations§
Source§impl RuleViolation
impl RuleViolation
Sourcepub fn new(rule_name: &'static str, message: impl Into<String>) -> Self
pub fn new(rule_name: &'static str, message: impl Into<String>) -> Self
Create a new violation with the given rule name and message.
Sourcepub fn at(self, position: usize) -> Self
pub fn at(self, position: usize) -> Self
Set the byte position where the violation was detected.
Sourcepub fn with_fragment(self, fragment: impl Into<String>) -> Self
pub fn with_fragment(self, fragment: impl Into<String>) -> Self
Set the problematic fragment.
Trait Implementations§
Source§impl Clone for RuleViolation
impl Clone for RuleViolation
Source§fn clone(&self) -> RuleViolation
fn clone(&self) -> RuleViolation
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 RuleViolation
impl Debug for RuleViolation
Source§impl Display for RuleViolation
impl Display for RuleViolation
Source§impl PartialEq for RuleViolation
impl PartialEq for RuleViolation
impl Eq for RuleViolation
impl StructuralPartialEq for RuleViolation
Auto Trait Implementations§
impl Freeze for RuleViolation
impl RefUnwindSafe for RuleViolation
impl Send for RuleViolation
impl Sync for RuleViolation
impl Unpin for RuleViolation
impl UnsafeUnpin for RuleViolation
impl UnwindSafe for RuleViolation
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