From 910657c755f7c7a3ed2018cacb76943a38310f04 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 8 May 2026 20:15:56 +0200 Subject: [PATCH] Lifetimes --- parser/src/ast.rs | 1 + parser/src/lib.rs | 5 +++++ src/codegen.rs | 1 + 3 files changed, 7 insertions(+) diff --git a/parser/src/ast.rs b/parser/src/ast.rs index 8ecb25e..85c3713 100644 --- a/parser/src/ast.rs +++ b/parser/src/ast.rs @@ -41,6 +41,7 @@ pub enum TypeExprKind { Path(Path), PathParams(Path, Vec), Tuple(Vec), + Lifetime(Identifier), } #[derive(Debug, Clone, Serialize)] diff --git a/parser/src/lib.rs b/parser/src/lib.rs index 1996de7..caf663f 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -36,6 +36,11 @@ impl From> for TypeExpr { TypeExprKind::from(inner.next().unwrap()), inner.map(TypePostfix::from).collect(), ), + Rule::type_expr_param => TypeExpr::from(inner.next().unwrap()), + Rule::lifetime => TypeExpr( + TypeExprKind::Lifetime(Identifier::from(inner.next().unwrap())), + Vec::new(), + ), _ => unimplemented!("{rule:#?}"), } } diff --git a/src/codegen.rs b/src/codegen.rs index a107cc2..7030837 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -96,6 +96,7 @@ impl GetRust for TypeExprKind { fn get_rust(&self) -> String { match self { TypeExprKind::Path(path) => get_static_type_path(path), + TypeExprKind::Lifetime(name) => format!("'{}", name.get_rust()), TypeExprKind::PathParams(path, params) => { format!( "{}<{}>",