Remove Option unwraping

This commit is contained in:
Geoffrey Copin 2020-04-11 12:58:20 +02:00
parent 730a927c5e
commit 21443f1b48

View file

@ -27,9 +27,9 @@ fn reorder_struct(ctx: AssistCtx) -> Option<Assist> {
fn field_name(r: &RecordField) -> String {
r.name_ref()
.map(|name| name.syntax().text())
.unwrap_or_else(|| r.expr().unwrap().syntax().text())
.to_string()
.map(|name| name.syntax().text().to_string())
.or_else(|| r.expr().map(|e| e.syntax().text().to_string()))
.unwrap_or_default()
}
fn reorder_struct_pat(ctx: AssistCtx) -> Option<Assist> {