Mutable ref

This commit is contained in:
2026-05-04 18:00:50 +02:00
parent a057c50a53
commit 860f51ea06
4 changed files with 10 additions and 4 deletions
+1
View File
@@ -14,6 +14,7 @@ pub struct Block(pub Vec<Statement>);
#[derive(Debug, Clone, Serialize)]
pub enum TypePostfix {
Ref,
RefMut,
}
#[derive(Debug, Clone, Serialize)]
+1 -1
View File
@@ -75,7 +75,7 @@ while_stmt = {
// ================= EXPRESSIONS =================
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
ref_type = { "*" }
ref_type = { mutable? ~ "*" }
type_expr = { (path_type | tuple_type) ~ ref_type* }
primary = {
+7 -3
View File
@@ -44,9 +44,13 @@ impl From<pest::iterators::Pair<'_, Rule>> for TypeExpr {
impl From<pest::iterators::Pair<'_, Rule>> for TypePostfix {
fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self {
match pair.as_rule() {
Rule::ref_type => match pair.as_str().trim() {
_ => Self::Ref,
},
Rule::ref_type => {
if pair.into_inner().peek().is_some() {
TypePostfix::RefMut
} else {
TypePostfix::Ref
}
}
_ => unimplemented!("{pair:#?}"),
}
}