From 0f654b06ab093e7bb057cfd68b27925803b003d8 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 14 Jul 2020 13:12:16 +0200 Subject: missing impl members: remove assoc. type bounds --- crates/ra_syntax/src/ast/make.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/ra_syntax/src/ast/make.rs') diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 192c610f1..42116afbb 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -64,6 +64,19 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { ast_from_text(&format!("use {};", use_tree)) } +pub fn type_alias_def( + name: ast::Name, + bounds: Option, + ty: Option, +) -> ast::TypeAliasDef { + match (bounds, ty) { + (None, None) => ast_from_text(&format!("type {};", name)), + (None, Some(ty)) => ast_from_text(&format!("type {} = {};", name, ty)), + (Some(bounds), None) => ast_from_text(&format!("type {}: {};", name, bounds)), + (Some(bounds), Some(ty)) => ast_from_text(&format!("type {}: {} = {};", name, bounds, ty)), + } +} + pub fn record_field(name: ast::NameRef, expr: Option) -> ast::RecordField { return match expr { Some(expr) => from_text(&format!("{}: {}", name, expr)), -- cgit v1.2.3