diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-30 17:52:59 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-30 17:52:59 +0100 |
commit | bc8610e2b58fe101ddc34d0ce389cfa829060c62 (patch) | |
tree | fac9cf9a1ac4e4e28570261f2e755aa4f92f904d /crates/ra_syntax/src/ast/node_ext.rs | |
parent | af8132e610d1e649e67ab797e372d1efcf106c48 (diff) | |
parent | 3dce34aaf83c67836c94a526cb90eba8f36e3985 (diff) |
Merge #5608
5608: Introduce GenericParam r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast/node_ext.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 313f52226..d2ee9586d 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -473,6 +473,27 @@ impl ast::TokenTree { | |||
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | impl ast::GenericParamList { | ||
477 | pub fn lifetime_params(&self) -> impl Iterator<Item = ast::LifetimeParam> { | ||
478 | self.generic_params().filter_map(|param| match param { | ||
479 | ast::GenericParam::LifetimeParam(it) => Some(it), | ||
480 | ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
481 | }) | ||
482 | } | ||
483 | pub fn type_params(&self) -> impl Iterator<Item = ast::TypeParam> { | ||
484 | self.generic_params().filter_map(|param| match param { | ||
485 | ast::GenericParam::TypeParam(it) => Some(it), | ||
486 | ast::GenericParam::LifetimeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
487 | }) | ||
488 | } | ||
489 | pub fn const_params(&self) -> impl Iterator<Item = ast::ConstParam> { | ||
490 | self.generic_params().filter_map(|param| match param { | ||
491 | ast::GenericParam::ConstParam(it) => Some(it), | ||
492 | ast::GenericParam::TypeParam(_) | ast::GenericParam::LifetimeParam(_) => None, | ||
493 | }) | ||
494 | } | ||
495 | } | ||
496 | |||
476 | impl ast::DocCommentsOwner for ast::SourceFile {} | 497 | impl ast::DocCommentsOwner for ast::SourceFile {} |
477 | impl ast::DocCommentsOwner for ast::Fn {} | 498 | impl ast::DocCommentsOwner for ast::Fn {} |
478 | impl ast::DocCommentsOwner for ast::Struct {} | 499 | impl ast::DocCommentsOwner for ast::Struct {} |