diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2024-08-22 14:40:55 +0300 |
|---|---|---|
| committer | Chayim Refael Friedman <chayimfr@gmail.com> | 2024-08-24 23:46:32 +0300 |
| commit | 634052268fec5ad208e8e1b461904c12fadb8dc4 (patch) | |
| tree | c34e3af9bd4a92c8e5e83ba85199c4a57956277c | |
| parent | 73393377938ffafa3d913bb11e9046338fa0d1a9 (diff) | |
| download | rust-634052268fec5ad208e8e1b461904c12fadb8dc4.tar.gz rust-634052268fec5ad208e8e1b461904c12fadb8dc4.zip | |
Provide `impl From<ast::TypeOrConstParam> for ast::GenericParam`
| -rw-r--r-- | src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs index 5447906206c..693bfe330bd 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs @@ -17,7 +17,7 @@ use crate::{ ted, NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T, }; -use super::{RangeItem, RangeOp}; +use super::{GenericParam, RangeItem, RangeOp}; impl ast::Lifetime { pub fn text(&self) -> TokenText<'_> { @@ -822,6 +822,15 @@ pub enum TypeOrConstParam { Const(ast::ConstParam), } +impl From<TypeOrConstParam> for GenericParam { + fn from(value: TypeOrConstParam) -> Self { + match value { + TypeOrConstParam::Type(it) => GenericParam::TypeParam(it), + TypeOrConstParam::Const(it) => GenericParam::ConstParam(it), + } + } +} + impl TypeOrConstParam { pub fn name(&self) -> Option<ast::Name> { match self { |
