Provide impl From<ast::TypeOrConstParam> for ast::GenericParam

This commit is contained in:
Chayim Refael Friedman 2024-08-22 14:40:55 +03:00
parent ddbb28daa0
commit 5c59a718c5

View file

@ -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 {