pub struct Lintable<T> {
content: T,
raw: Option<String>,
fix: bool,
path: PathBuf,
workspace_dir: PathBuf,
modified: bool,
failed: AtomicBool,
}Expand description
A wrapper around file content for linting.
Most lints will want to use the Deref impl to access the content directly,
but this also provides utilities for reporting errors and making fixes.
Fields§
§content: T§raw: Option<String>§fix: bool§path: PathBuf§workspace_dir: PathBuf§modified: bool§failed: AtomicBoolImplementations§
Source§impl<T> Lintable<T>
impl<T> Lintable<T>
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Get the path of this file relative to the workspace root, for use in error messages.
Sourcepub fn raw(&self) -> Option<&str>
pub fn raw(&self) -> Option<&str>
Get the original raw file content as a string, for lints that need to do their own parsing.
If the file content is already a string this will be None. This field is not modified when fixes are made.
Sourcepub fn fix(&mut self, description: &str, op: impl FnOnce(&mut T))
pub fn fix(&mut self, description: &str, op: impl FnOnce(&mut T))
If fix is enabled, apply the given fix operation to the content and mark it modified. If fix is not enabled, report an error with the given description.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Lintable<T>
impl<T> RefUnwindSafe for Lintable<T>where
T: RefUnwindSafe,
impl<T> Send for Lintable<T>where
T: Send,
impl<T> Sync for Lintable<T>where
T: Sync,
impl<T> Unpin for Lintable<T>where
T: Unpin,
impl<T> UnsafeUnpin for Lintable<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Lintable<T>where
T: UnwindSafe,
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