diff options
Diffstat (limited to 'crates/syntax/src/ast/make.rs')
-rw-r--r-- | crates/syntax/src/ast/make.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index c2c938ad1..7329e3039 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -294,6 +294,21 @@ pub fn param_list(pats: impl IntoIterator<Item = ast::Param>) -> ast::ParamList | |||
294 | ast_from_text(&format!("fn f({}) {{ }}", args)) | 294 | ast_from_text(&format!("fn f({}) {{ }}", args)) |
295 | } | 295 | } |
296 | 296 | ||
297 | pub fn generic_param(name: String, ty: Option<String>) -> ast::GenericParam { | ||
298 | let bound = match ty { | ||
299 | Some(it) => format!(": {}", it), | ||
300 | None => String::new(), | ||
301 | }; | ||
302 | ast_from_text(&format!("fn f<{}{}>() {{ }}", name, bound)) | ||
303 | } | ||
304 | |||
305 | pub fn generic_param_list( | ||
306 | pats: impl IntoIterator<Item = ast::GenericParam>, | ||
307 | ) -> ast::GenericParamList { | ||
308 | let args = pats.into_iter().join(", "); | ||
309 | ast_from_text(&format!("fn f<{}>() {{ }}", args)) | ||
310 | } | ||
311 | |||
297 | pub fn visibility_pub_crate() -> ast::Visibility { | 312 | pub fn visibility_pub_crate() -> ast::Visibility { |
298 | ast_from_text("pub(crate) struct S") | 313 | ast_from_text("pub(crate) struct S") |
299 | } | 314 | } |