Generate doc

This commit is contained in:
Geoffrey Copin 2020-04-11 20:32:58 +02:00
parent d362fcfc1c
commit d9089245fe
2 changed files with 30 additions and 0 deletions

View file

@ -606,6 +606,21 @@ impl Walrus {
)
}
#[test]
fn doctest_reorder_fields() {
check(
"reorder_fields",
r#####"
struct Foo {foo: i32, bar: i32};
const test: Foo = <|>Foo {bar: 0, foo: 1}
"#####,
r#####"
struct Foo {foo: i32, bar: i32};
const test: Foo = Foo {foo: 1, bar: 0}
"#####,
)
}
#[test]
fn doctest_replace_if_let_with_match() {
check(

View file

@ -582,6 +582,21 @@ impl Walrus {
}
```
## `reorder_fields`
Reorder the fields of record literals and record patterns in the same order as in
the definition.
```rust
// 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}
```
## `replace_if_let_with_match`
Replaces `if let` with an else branch with a `match` expression.