pub struct Violation {
pub path: Option<Arc<Path>>,
pub message: Cow<'static, str>,
pub line: Option<usize>,
pub column: Option<usize>,
}Expand description
A single linting violation produced by a rule.
path holds an Arc<Path>; rules clone the Arc from
FileEntry::path (a cheap
atomic refcount bump) rather than copying the path bytes. At
100k violations this saves 100k path-byte allocations.
message is a Cow<'static, str>; per-match templated
messages live as Cow::Owned(String) (no change in cost),
while fixed messages can live as Cow::Borrowed("…") if a
rule chooses to construct them that way. Public API on the
struct is unchanged at the byte level — Display and serde
Serialize impls go through the inner &str / &Path.
Fields§
§path: Option<Arc<Path>>§message: Cow<'static, str>§line: Option<usize>§column: Option<usize>Implementations§
Source§impl Violation
impl Violation
pub fn new(message: impl Into<Cow<'static, str>>) -> Self
Sourcepub fn with_path(self, path: impl Into<Arc<Path>>) -> Self
pub fn with_path(self, path: impl Into<Arc<Path>>) -> Self
Attach a path to the violation. Accepts anything convertible
into Arc<Path> — the canonical caller is
.with_path(entry.path.clone()) where entry.path is the
Arc<Path> already owned by the FileIndex; this clones
the Arc (atomic refcount bump) rather than the bytes.
PathBuf, &Path, and Box<Path> are also accepted via
std’s From impls; for an ad-hoc &str use
Path::new("a.rs") to convert first.
pub fn with_location(self, line: usize, column: usize) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Violation
impl RefUnwindSafe for Violation
impl Send for Violation
impl Sync for Violation
impl Unpin for Violation
impl UnsafeUnpin for Violation
impl UnwindSafe for Violation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more