aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/reorder_fields.rs
diff options
context:
space:
mode:
authorGeoffrey Copin <[email protected]>2020-04-11 18:39:10 +0100
committerGeoffrey Copin <[email protected]>2020-04-11 18:39:10 +0100
commit25a0ce2e9e59ca09665055c053d0008b7bbb9cb7 (patch)
treea906875a09bdff2394b0c33a19855d3761138b66 /crates/ra_assists/src/handlers/reorder_fields.rs
parent270bcfdfc226bcdfffd7b8aa903073929fcef5f2 (diff)
Add documentation comment
Diffstat (limited to 'crates/ra_assists/src/handlers/reorder_fields.rs')
-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}