pub struct BuiltinRules;Expand description
Collection of built-in codemod rules.
Implementations§
Source§impl BuiltinRules
impl BuiltinRules
Sourcepub fn all() -> Vec<CodemodRule>
pub fn all() -> Vec<CodemodRule>
Returns all built-in rules.
Sourcepub fn get(name: &str) -> Option<CodemodRule>
pub fn get(name: &str) -> Option<CodemodRule>
Get a built-in rule by name, or None if not found.
Sourcepub fn replace_println_with_log() -> CodemodRule
pub fn replace_println_with_log() -> CodemodRule
Replace println! calls with log::info!.
This is one of the most common Rust codemods — switching from ad-hoc
println! debugging to structured logging.
before: "println!($args)"
after: "log::info!($args)"Sourcepub fn replace_unwrap_with_expect() -> CodemodRule
pub fn replace_unwrap_with_expect() -> CodemodRule
Replace .unwrap() calls with .expect("descriptive message").
Bare .unwrap() calls produce unhelpful panic messages. This rule
replaces them with .expect() so developers can add context.
before: "$expr.unwrap()"
after: "$expr.expect(\"TODO: add error context\")"Sourcepub fn replace_deprecated_trim() -> CodemodRule
pub fn replace_deprecated_trim() -> CodemodRule
Replace the deprecated trim_left() / trim_right() with
trim_start() / trim_end() (Rust 1.30+).
before: "$s.trim_left()"
after: "$s.trim_start()"Auto Trait Implementations§
impl Freeze for BuiltinRules
impl RefUnwindSafe for BuiltinRules
impl Send for BuiltinRules
impl Sync for BuiltinRules
impl Unpin for BuiltinRules
impl UnsafeUnpin for BuiltinRules
impl UnwindSafe for BuiltinRules
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
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>
Converts
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>
Converts
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