aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/reorder_fields.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs
index 100e1feb1..661c1bf54 100644
--- a/crates/ra_assists/src/handlers/reorder_fields.rs
+++ b/crates/ra_assists/src/handlers/reorder_fields.rs
@@ -16,6 +16,22 @@ use crate::{
16}; 16};
17use ra_syntax::ast::{Expr, NameRef}; 17use ra_syntax::ast::{Expr, NameRef};
18 18
19
20// Assist: reorder_fields
21//
22// Reorder the fields of record literals and record patterns in the same order as in
23// the definition.
24//
25// ```
26// struct Foo {foo: i32, bar: i32};
27// const test: Foo = <|>Foo {bar: 0, foo: 1}
28// ```
29// ->
30// ```
31// struct Foo {foo: i32, bar: i32};
32// const test: Foo = <|>Foo {foo: 1, bar: 0}
33// ```
34//
19pub(crate) fn reorder_fields(ctx: AssistCtx) -> Option<Assist> { 35pub(crate) fn reorder_fields(ctx: AssistCtx) -> Option<Assist> {
20 reorder::<RecordLit>(ctx.clone()).or_else(|| reorder::<RecordPat>(ctx)) 36 reorder::<RecordLit>(ctx.clone()).or_else(|| reorder::<RecordPat>(ctx))
21} 37}