Skip to content

Commit

Permalink
Provide impl From<ast::TypeOrConstParam> for ast::GenericParam
Browse files Browse the repository at this point in the history
  • Loading branch information
ChayimFriedman2 committed Aug 24, 2024
1 parent ddbb28d commit 5c59a71
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/syntax/src/ast/node_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_> {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5c59a71

Please sign in to comment.