Mutable ref
This commit is contained in:
@@ -14,6 +14,7 @@ pub struct Block(pub Vec<Statement>);
|
|||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub enum TypePostfix {
|
pub enum TypePostfix {
|
||||||
Ref,
|
Ref,
|
||||||
|
RefMut,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ while_stmt = {
|
|||||||
// ================= EXPRESSIONS =================
|
// ================= EXPRESSIONS =================
|
||||||
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
||||||
path_type = { static_path ~ ("<" ~ (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* }
|
type_expr = { (path_type | tuple_type) ~ ref_type* }
|
||||||
|
|
||||||
primary = {
|
primary = {
|
||||||
|
|||||||
+7
-3
@@ -44,9 +44,13 @@ impl From<pest::iterators::Pair<'_, Rule>> for TypeExpr {
|
|||||||
impl From<pest::iterators::Pair<'_, Rule>> for TypePostfix {
|
impl From<pest::iterators::Pair<'_, Rule>> for TypePostfix {
|
||||||
fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self {
|
fn from(pair: pest::iterators::Pair<'_, Rule>) -> Self {
|
||||||
match pair.as_rule() {
|
match pair.as_rule() {
|
||||||
Rule::ref_type => match pair.as_str().trim() {
|
Rule::ref_type => {
|
||||||
_ => Self::Ref,
|
if pair.into_inner().peek().is_some() {
|
||||||
},
|
TypePostfix::RefMut
|
||||||
|
} else {
|
||||||
|
TypePostfix::Ref
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => unimplemented!("{pair:#?}"),
|
_ => unimplemented!("{pair:#?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ impl GetRust for TypePostfix {
|
|||||||
fn get_rust(&self) -> String {
|
fn get_rust(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
TypePostfix::Ref => format!("&"),
|
TypePostfix::Ref => format!("&"),
|
||||||
|
TypePostfix::RefMut => format!("&mut "),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user