Skip to content

Latest commit

 

History

History
2418 lines (1878 loc) · 41.9 KB

File metadata and controls

2418 lines (1878 loc) · 41.9 KB

add_explicit_type

Specify type for a let binding.

Before
fn main() {
    let x┃ = 92;
}
After
fn main() {
    let x: i32 = 92;
}

add_hash

Source: raw_string.rs

Adds a hash to a raw string literal.

Before
fn main() {
    r#"Hello,┃ World!"#;
}
After
fn main() {
    r##"Hello, World!"##;
}

add_impl_default_members

Adds scaffold for overriding default impl members.

Before
trait Trait {
    type X;
    fn foo(&self);
    fn bar(&self) {}
}

impl Trait for () {
    type X = ();
    fn foo(&self) {}}
After
trait Trait {
    type X;
    fn foo(&self);
    fn bar(&self) {}
}

impl Trait for () {
    type X = ();
    fn foo(&self) {}fn bar(&self) {}
}

add_impl_missing_members

Adds scaffold for required impl members.

Before
trait Trait<T> {
    type X;
    fn foo(&self) -> T;
    fn bar(&self) {}
}

impl Trait<u32> for () {}
After
trait Trait<T> {
    type X;
    fn foo(&self) -> T;
    fn bar(&self) {}
}

impl Trait<u32> for () {type X;

    fn foo(&self) -> u32 {
        todo!()
    }
}

add_lifetime_to_type

Adds a new lifetime to a struct, enum or union.

Before
struct Point {
    x: &u32,
    y: u32,
}
After
struct Point<'a> {
    x: &'a u32,
    y: u32,
}

add_missing_match_arms

Adds missing clauses to a match expression.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {}
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {Action::Move { distance } => todo!(),
        Action::Stop => todo!(),
    }
}

add_return_type

Adds the return type to a function or closure inferred from its tail expression if it doesn’t have a return type specified. This assists is useable in a functions or closures tail expression or return type position.

Before
fn foo() { 42i32 }
After
fn foo() -> i32 { 42i32 }

add_turbo_fish

Adds ::<_> to a call of a generic method or function.

Before
fn make<T>() -> T { todo!() }
fn main() {
    let x = make();
}
After
fn make<T>() -> T { todo!() }
fn main() {
    let x = make::<${0:_}>();
}

apply_demorgan

Apply De Morgan’s law. This transforms expressions of the form !l || !r into !(l && r). This also works with &&. This assist can only be applied with the cursor on either || or &&.

Before
fn main() {
    if x != 4 ||┃ y < 3.14 {}
}
After
fn main() {
    if !(x == 4 && y >= 3.14) {}
}

auto_import

Source: auto_import.rs

If the name is unresolved, provides all possible imports for it.

Before
fn main() {
    let map = HashMap::new();
}
After
use std::collections::HashMap;

fn main() {
    let map = HashMap::new();
}

change_visibility

Adds or changes existing visibility specifier.

Before
fn frobnicate() {}
After
pub(crate) fn frobnicate() {}

convert_bool_then_to_if

Converts a bool::then method call to an equivalent if expression.

Before
fn main() {
    (0 == 0).then(|| val)
}
After
fn main() {
    if 0 == 0 {
        Some(val)
    } else {
        None
    }
}

convert_for_loop_with_for_each

Converts a for loop into a for_each loop on the Iterator.

Before
fn main() {
    let x = vec![1, 2, 3];
    for┃ v in x {
        let y = v * 2;
    }
}
After
fn main() {
    let x = vec![1, 2, 3];
    x.into_iter().for_each(|v| {
        let y = v * 2;
    });
}

convert_if_to_bool_then

Converts an if expression into a corresponding bool::then call.

Before
fn main() {
    if┃ cond {
        Some(val)
    } else {
        None
    }
}
After
fn main() {
    cond.then(|| val)
}

convert_integer_literal

Converts the base of integer literals to other bases.

Before
const _: i32 = 10;
After
const _: i32 = 0b1010;

convert_into_to_from

Converts an Into impl to an equivalent From impl.

Before
implInto<Thing> for usize {
    fn into(self) -> Thing {
        Thing {
            b: self.to_string(),
            a: self
        }
    }
}
After
impl From<usize> for Thing {
    fn from(val: usize) -> Self {
        Thing {
            b: val.to_string(),
            a: val
        }
    }
}

convert_iter_for_each_to_for

Converts an Iterator::for_each function into a for loop.

Before
fn main() {
    let iter = iter::repeat((9, 2));
    iter.for_each(|(x, y)| {
        println!("x: {}, y: {}", x, y);
    });
}
After
fn main() {
    let iter = iter::repeat((9, 2));
    for (x, y) in iter {
        println!("x: {}, y: {}", x, y);
    }
}

convert_to_guarded_return

Replace a large conditional with a guarded return.

Before
fn main() {if cond {
        foo();
        bar();
    }
}
After
fn main() {
    if !cond {
        return;
    }
    foo();
    bar();
}

convert_tuple_struct_to_named_struct

Converts tuple struct to struct with named fields, and analogously for tuple enum variants.

Before
struct Point(f32, f32);

impl Point {
    pub fn new(x: f32, y: f32) -> Self {
        Point(x, y)
    }

    pub fn x(&self) -> f32 {
        self.0
    }

    pub fn y(&self) -> f32 {
        self.1
    }
}
After
struct Point { field1: f32, field2: f32 }

impl Point {
    pub fn new(x: f32, y: f32) -> Self {
        Point { field1: x, field2: y }
    }

    pub fn x(&self) -> f32 {
        self.field1
    }

    pub fn y(&self) -> f32 {
        self.field2
    }
}

convert_while_to_loop

Replace a while with a loop.

Before
fn main() {while cond {
        foo();
    }
}
After
fn main() {
    loop {
        if !cond {
            break;
        }
        foo();
    }
}

destructure_tuple_binding

Destructures a tuple binding in place.

Before
fn main() {
    let ┃t = (1,2);
    let v = t.0;
}
After
fn main() {
    let (┃_0, _1) = (1,2);
    let v = _0;
}

expand_glob_import

Expands glob imports.

Before
mod foo {
    pub struct Bar;
    pub struct Baz;
}

use foo::*;

fn qux(bar: Bar, baz: Baz) {}
After
mod foo {
    pub struct Bar;
    pub struct Baz;
}

use foo::{Baz, Bar};

fn qux(bar: Bar, baz: Baz) {}

extract_function

Extracts selected statements into new function.

Before
fn main() {
    let n = 1;let m = n + 2;
    let k = m + n;let g = 3;
}
After
fn main() {
    let n = 1;
    fun_name(n);
    let g = 3;
}

fnfun_name(n: i32) {
    let m = n + 2;
    let k = m + n;
}

extract_module

Extracts a selected region as seperate module. All the references, visibility and imports are resolved.

Before
fn foo(name: i32) -> i32 {
    name + 1
}fn bar(name: i32) -> i32 {
    name + 2
}
After
mod modname {
    pub(crate) fn foo(name: i32) -> i32 {
        name + 1
    }
}

fn bar(name: i32) -> i32 {
    name + 2
}

extract_struct_from_enum_variant

Extracts a struct from enum variant.

Before
enum A {One(u32, u32) }
After
struct One(u32, u32);

enum A { One(One) }

extract_type_alias

Extracts the selected type as a type alias.

Before
struct S {
    field:(u8, u8, u8),
}
After
typeType = (u8, u8, u8);

struct S {
    field: Type,
}

extract_variable

Extracts subexpression into a variable.

Before
fn main() {(1 + 2)* 4;
}
After
fn main() {
    let ┃var_name = (1 + 2);
    var_name * 4;
}

fix_visibility

Makes inaccessible item public.

Before
mod m {
    fn frobnicate() {}
}
fn main() {
    m::frobnicate() {}
}
After
mod m {pub(crate) fn frobnicate() {}
}
fn main() {
    m::frobnicate() {}
}

flip_binexpr

Source: flip_binexpr.rs

Flips operands of a binary expression.

Before
fn main() {
    let _ = 90 +┃ 2;
}
After
fn main() {
    let _ = 2 + 90;
}

flip_comma

Source: flip_comma.rs

Flips two comma-separated items.

Before
fn main() {
    ((1, 2),(3, 4));
}
After
fn main() {
    ((3, 4), (1, 2));
}

flip_trait_bound

Flips two trait bounds.

Before
fn foo<T: Clone +┃ Copy>() { }
After
fn foo<T: Copy + Clone>() { }

generate_constant

Generate a named constant.

Before
struct S { i: usize }
impl S { pub fn new(n: usize) {} }
fn main() {
    let v = S::new(CAPACITY);
}
After
struct S { i: usize }
impl S { pub fn new(n: usize) {} }
fn main() {
    const CAPACITY: usize = ┃;
    let v = S::new(CAPACITY);
}

generate_default_from_enum_variant

Adds a Default impl for an enum using a variant.

Before
enum Version {
 Undefined,
 Minor,
 Major,
}
After
enum Version {
 Undefined,
 Minor,
 Major,
}

impl Default for Version {
    fn default() -> Self {
        Self::Minor
    }
}

generate_default_from_new

Generates default implementation from new method.

Before
struct Example { _inner: () }

impl Example {
    pub fn n┃ew() -> Self {
        Self { _inner: () }
    }
}
After
struct Example { _inner: () }

impl Example {
    pub fn new() -> Self {
        Self { _inner: () }
    }
}

impl Default for Example {
    fn default() -> Self {
        Self::new()
    }
}

generate_delegate_methods

Generate delegate methods.

Before
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    ag┃e: Age,
}
After
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    age: Age,
}

impl Person {fn age(&self) -> u8 {
        self.age.age()
    }
}

generate_deref

Generate Deref impl using the given struct field.

Before
struct A;
struct B {a: A
}
After
struct A;
struct B {
   a: A
}

impl std::ops::Deref for B {
    type Target = A;

    fn deref(&self) -> &Self::Target {
        &self.a
    }
}

generate_derive

Adds a new #[derive()] clause to a struct or enum.

Before
struct Point {
    x: u32,
    y: u32,}
After
#[derive()]
struct Point {
    x: u32,
    y: u32,
}

generate_enum_as_method

Generate an as_ method for an enum variant.

Before
enum Value {
 Number(i32),
 Text(String),
}
After
enum Value {
 Number(i32),
 Text(String),
}

impl Value {
    fn as_text(&self) -> Option<&String> {
        if let Self::Text(v) = self {
            Some(v)
        } else {
            None
        }
    }
}

generate_enum_is_method

Generate an is_ method for an enum variant.

Before
enum Version {
 Undefined,
 Minor,
 Major,
}
After
enum Version {
 Undefined,
 Minor,
 Major,
}

impl Version {
    /// Returns `true` if the version is [`Minor`].
    ///
    /// [`Minor`]: Version::Minor
    fn is_minor(&self) -> bool {
        matches!(self, Self::Minor)
    }
}

generate_enum_try_into_method

Generate an try_into_ method for an enum variant.

Before
enum Value {
 Number(i32),
 Text(String),
}
After
enum Value {
 Number(i32),
 Text(String),
}

impl Value {
    fn try_into_text(self) -> Result<String, Self> {
        if let Self::Text(v) = self {
            Ok(v)
        } else {
            Err(self)
        }
    }
}

generate_from_impl_for_enum

Adds a From impl for an enum variant with one tuple field.

Before
enum A {One(u32) }
After
enum A { One(u32) }

impl From<u32> for A {
    fn from(v: u32) -> Self {
        Self::One(v)
    }
}

generate_function

Adds a stub function with a signature matching the function under the cursor.

Before
struct Baz;
fn baz() -> Baz { Baz }
fn foo() {
    bar("", baz());
}
After
struct Baz;
fn baz() -> Baz { Baz }
fn foo() {
    bar("", baz());
}

fn bar(arg: &str, baz: Baz) ${0:-> _} {
    todo!()
}

generate_getter

Generate a getter method.

Before
struct Person {
    nam┃e: String,
}
After
struct Person {
    name: String,
}

impl Person {
    /// Get a reference to the person's name.
    fnname(&self) -> &str {
        self.name.as_ref()
    }
}

generate_getter_mut

Generate a mut getter method.

Before
struct Person {
    nam┃e: String,
}
After
struct Person {
    name: String,
}

impl Person {
    /// Get a mutable reference to the person's name.
    fnname_mut(&mut self) -> &mut String {
        &mut self.name
    }
}

generate_impl

Adds a new inherent impl for a type.

Before
struct Ctx<T: Clone> {
    data: T,}
After
struct Ctx<T: Clone> {
    data: T,
}

impl<T: Clone> Ctx<T> {}

generate_is_empty_from_len

Generates is_empty implementation from the len method.

Before
struct MyStruct { data: Vec<String> }

impl MyStruct {
    p┃ub fn len(&self) -> usize {
        self.data.len()
    }
}
After
struct MyStruct { data: Vec<String> }

impl MyStruct {
    pub fn len(&self) -> usize {
        self.data.len()
    }

    pub fn is_empty(&self) -> bool {
        self.len() == 0
    }
}

generate_new

Source: generate_new.rs

Adds a new inherent impl for a type.

Before
struct Ctx<T: Clone> {
     data: T,}
After
struct Ctx<T: Clone> {
     data: T,
}

impl<T: Clone> Ctx<T> {
    fnnew(data: T) -> Self { Self { data } }
}

generate_setter

Generate a setter method.

Before
struct Person {
    nam┃e: String,
}
After
struct Person {
    name: String,
}

impl Person {
    /// Set the person's name.
    fn set_name(&mut self, name: String) {
        self.name = name;
    }
}

inline_call

Source: inline_call.rs

Inlines a function or method body creating a let statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local or if the parameter is only accessed inside the function body once.

Before
fn foo(name: Option<&str>) {
    let name = name.unwrap();
}
After
fn foo(name: Option<&str>) {
    let name = match name {
            Some(val) => val,
            None => panic!("called `Option::unwrap()` on a `None` value"),
        };
}

inline_into_callers

Source: inline_call.rs

Inline a function or method body into all of its callers where possible, creating a let statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local or if the parameter is only accessed inside the function body once. If all calls can be inlined the function will be removed.

Before
fn print(_: &str) {}
fn foo(word: &str) {
    if !word.is_empty() {
        print(word);
    }
}
fn bar() {
    foo("안녕하세요");
    foo("여러분");
}
After
fn print(_: &str) {}

fn bar() {
    {
        let word = "안녕하세요";
        if !word.is_empty() {
            print(word);
        }
    };
    {
        let word = "여러분";
        if !word.is_empty() {
            print(word);
        }
    };
}

inline_local_variable

Inlines a local variable.

Before
fn main() {
    let x┃ = 1 + 2;
    x * 4;
}
After
fn main() {
    (1 + 2) * 4;
}

introduce_named_generic

Replaces impl Trait function argument with the named generic.

Before
fn foo(bar:impl Bar) {}
After
fn foo<B: Bar>(bar: B) {}

introduce_named_lifetime

Change an anonymous lifetime to a named lifetime.

Before
impl Cursor<'_> {
    fn node(self) -> &SyntaxNode {
        match self {
            Cursor::Replace(node) | Cursor::Before(node) => node,
        }
    }
}
After
impl<'a> Cursor<'a> {
    fn node(self) -> &SyntaxNode {
        match self {
            Cursor::Replace(node) | Cursor::Before(node) => node,
        }
    }
}

invert_if

Source: invert_if.rs

This transforms if expressions of the form if !x {A} else {B} into if x {B} else {A} This also works with !=. This assist can only be applied with the cursor on if.

Before
fn main() {
    if┃ !y { A } else { B }
}
After
fn main() {
    if y { B } else { A }
}

line_to_block

Converts comments between block and single-line form.

Before
   // Multi-line┃
   // comment
After
  /*
  Multi-line
  comment
  */

make_raw_string

Source: raw_string.rs

Adds r# to a plain string literal.

Before
fn main() {
    "Hello,┃ World!";
}
After
fn main() {
    r#"Hello, World!"#;
}

make_usual_string

Source: raw_string.rs

Turns a raw string into a plain string.

Before
fn main() {
    r#"Hello,┃ "World!""#;
}
After
fn main() {
    "Hello, \"World!\"";
}

merge_imports

Merges two imports with a common prefix.

Before
use std::┃fmt::Formatter;
use std::io;
After
use std::{fmt::Formatter, io};

merge_match_arms

Merges the current match arm with the following if their bodies are identical.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {Action::Move(..) => foo(),
        Action::Stop => foo(),
    }
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move(..) | Action::Stop => foo(),
    }
}

move_arm_cond_to_match_guard

Source: move_guard.rs

Moves if expression from match arm body into a guard.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move { distance } => ┃if distance > 10 { foo() },
        _ => (),
    }
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move { distance } if distance > 10 => foo(),
        _ => (),
    }
}

move_bounds_to_where_clause

Source: move_bounds.rs

Moves inline type bounds to a where clause.

Before
fn apply<T, U,F: FnOnce(T) -> U>(f: F, x: T) -> U {
    f(x)
}
After
fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
    f(x)
}

move_from_mod_rs

Moves xxx/mod.rs to xxx.rs.

Before
//- /main.rs
mod a;
//- /a/mod.rsfn t() {}
After
fn t() {}

move_guard_to_arm_body

Source: move_guard.rs

Moves match guard into match arm body.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move { distance }if distance > 10 => foo(),
        _ => (),
    }
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move { distance } => if distance > 10 {
            foo()
        },
        _ => (),
    }
}

move_module_to_file

Moves inline module’s contents to a separate file.

Before
mod ┃foo {
    fn t() {}
}
After
mod foo;

move_to_mod_rs

Moves xxx.rs to xxx/mod.rs.

Before
//- /main.rs
mod a;
//- /a.rsfn t() {}
After
fn t() {}

promote_local_to_const

Promotes a local variable to a const item changing its name to a SCREAMING_SNAKE_CASE variant if the local uses no non-const expressions.

Before
fn main() {
    let foo┃ = true;

    if foo {
        println!("It's true");
    } else {
        println!("It's false");
    }
}
After
fn main() {
    constFOO: bool = true;

    if FOO {
        println!("It's true");
    } else {
        println!("It's false");
    }
}

pull_assignment_up

Extracts variable assignment to outside an if or match statement.

Before
fn main() {
    let mut foo = 6;

    if true {
        ┃foo = 5;
    } else {
        foo = 4;
    }
}
After
fn main() {
    let mut foo = 6;

    foo = if true {
        5
    } else {
        4
    };
}

qualify_method_call

Replaces the method call with a qualified function call.

Before
struct Foo;
impl Foo {
    fn foo(&self) {}
}
fn main() {
    let foo = Foo;
    foo.fo┃o();
}
After
struct Foo;
impl Foo {
    fn foo(&self) {}
}
fn main() {
    let foo = Foo;
    Foo::foo(&foo);
}

qualify_path

Source: qualify_path.rs

If the name is unresolved, provides all possible qualified paths for it.

Before
fn main() {
    let map = HashMap::new();
}
After
fn main() {
    let map = std::collections::HashMap::new();
}

remove_dbg

Source: remove_dbg.rs

Removes dbg!() macro call.

Before
fn main() {dbg!(92);
}
After
fn main() {
    92;
}

remove_hash

Source: raw_string.rs

Removes a hash from a raw string literal.

Before
fn main() {
    r#"Hello,┃ World!"#;
}
After
fn main() {
    r"Hello, World!";
}

remove_mut

Source: remove_mut.rs

Removes the mut keyword.

Before
impl Walrus {
    fn feed(&mutself, amount: u32) {}
}
After
impl Walrus {
    fn feed(&self, amount: u32) {}
}

remove_unused_param

Removes unused function parameter.

Before
fn frobnicate(x: i32) {}

fn main() {
    frobnicate(92);
}
After
fn frobnicate() {}

fn main() {
    frobnicate();
}

reorder_fields

Reorder the fields of record literals and record patterns in the same order as in the definition.

Before
struct Foo {foo: i32, bar: i32};
const test: Foo = ┃Foo {bar: 0, foo: 1}
After
struct Foo {foo: i32, bar: i32};
const test: Foo = Foo {foo: 1, bar: 0}

reorder_impl

Source: reorder_impl.rs

Reorder the methods of an impl Trait. The methods will be ordered in the same order as in the trait definition.

Before
trait Foo {
    fn a() {}
    fn b() {}
    fn c() {}
}

struct Bar;impl Foo for Bar {
    fn b() {}
    fn c() {}
    fn a() {}
}
After
trait Foo {
    fn a() {}
    fn b() {}
    fn c() {}
}

struct Bar;
impl Foo for Bar {
    fn a() {}
    fn b() {}
    fn c() {}
}

replace_char_with_string

Replace a char literal with a string literal.

Before
fn main() {
    find('{');
}
After
fn main() {
    find("{");
}

replace_derive_with_manual_impl

Converts a derive impl into a manual one.

Before
#[derive(Deb┃ug, Display)]
struct S;
After
#[derive(Display)]
struct S;

impl Debug for S {fn fmt(&self, f: &mut Formatter) -> Result<()> {
        f.debug_struct("S").finish()
    }
}

replace_if_let_with_match

Replaces a if let expression with a match expression.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {if let Action::Move { distance } = action {
        foo(distance)
    } else {
        bar()
    }
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    match action {
        Action::Move { distance } => foo(distance),
        _ => bar(),
    }
}

replace_let_with_if_let

Replaces let with an if let.

Before
fn main(action: Action) {let x = compute();
}

fn compute() -> Option<i32> { None }
After
fn main(action: Action) {
    if let Some(x) = compute() {
    }
}

fn compute() -> Option<i32> { None }

replace_match_with_if_let

Replaces a binary match with a wildcard pattern and no guards with an if let expression.

Before
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {match action {
        Action::Move { distance } => foo(distance),
        _ => bar(),
    }
}
After
enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
    if let Action::Move { distance } = action {
        foo(distance)
    } else {
        bar()
    }
}

replace_qualified_name_with_use

Adds a use statement for a given fully-qualified name.

Before
fn process(map: std::collections::HashMap<String, String>) {}
After
use std::collections::HashMap;

fn process(map: HashMap<String, String>) {}

replace_string_with_char

Replace string literal with char literal.

Before
fn main() {
    find("{┃");
}
After
fn main() {
    find('{');
}

replace_try_expr_with_match

Replaces a try expression with a match expression.

Before
fn handle() {
    let pat = Some(true)┃?;
}
After
fn handle() {
    let pat = match Some(true) {
        Some(it) => it,
        None => return None,
    };
}

replace_turbofish_with_explicit_type

Converts ::<_> to an explicit type assignment.

Before
fn make<T>() -> T { ) }
fn main() {
    let a = make::<i32>();
}
After
fn make<T>() -> T { ) }
fn main() {
    let a: i32 = make();
}

sort_items

Source: sort_items.rs

Sorts item members alphabetically: fields, enum variants and methods.

Before
structFoo{ second: u32, first: String }
After
struct Foo { first: String, second: u32 }

Before
traitBar{
    fn second(&self) -> u32;
    fn first(&self) -> String;
}
After
trait Bar {
    fn first(&self) -> String;
    fn second(&self) -> u32;
}

Before
struct Baz;
implBaz{
    fn second(&self) -> u32;
    fn first(&self) -> String;
}
After
struct Baz;
impl Baz {
    fn first(&self) -> String;
    fn second(&self) -> u32;
}

There is a difference between sorting enum variants:

Before
enumAnimal{
  Dog(String, f64),
  Cat { weight: f64, name: String },
}
After
enum Animal {
  Cat { weight: f64, name: String },
  Dog(String, f64),
}

and sorting a single enum struct variant:

Before
enum Animal {
  Dog(String, f64),
  Cat{ weight: f64, name: String },
}
After
enum Animal {
  Dog(String, f64),
  Cat { name: String, weight: f64 },
}

split_import

Source: split_import.rs

Wraps the tail of import into braces.

Before
use std::┃collections::HashMap;
After
use std::{collections::HashMap};

toggle_ignore

Adds #[ignore] attribute to the test.

Before
#[test]
fn arithmetics {
    assert_eq!(2 + 2, 5);
}
After
#[test]
#[ignore]
fn arithmetics {
    assert_eq!(2 + 2, 5);
}

unmerge_use

Source: unmerge_use.rs

Extracts single use item from use list.

Before
use std::fmt::{Debug, Display};
After
use std::fmt::{Debug};
use std::fmt::Display;

unwrap_block

Source: unwrap_block.rs

This assist removes if…​else, for, while and loop control statements to just keep the body.

Before
fn foo() {
    if true {println!("foo");
    }
}
After
fn foo() {
    println!("foo");
}

unwrap_result_return_type

Unwrap the function’s return type.

Before
fn foo() -> Result<i32>{ Ok(42i32) }
After
fn foo() -> i32 { 42i32 }

wrap_return_type_in_result

Wrap the function’s return type into Result.

Before
fn foo() -> i32{ 42i32 }
After
fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }