forked from AbleScript/ablescript
Improve consistency of code & comments
Changed all `&str.to_string()` into `&str.to_owned()`, and made the grammar of the `Value::into_*` comments uniform.
This commit is contained in:
parent
1b9f8a6179
commit
7673b64a71
|
@ -201,7 +201,7 @@ impl ExecEnv {
|
|||
self.decl_var(
|
||||
&iden.iden,
|
||||
Value::Functio(Functio::AbleFunctio {
|
||||
params: params.iter().map(|iden| iden.iden.to_string()).collect(),
|
||||
params: params.iter().map(|iden| iden.iden.to_owned()).collect(),
|
||||
body: body.block.to_owned(),
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -558,7 +558,7 @@ mod tests {
|
|||
rhs: Box::new(Expr {
|
||||
kind: ExprKind::BinOp {
|
||||
lhs: Box::new(Expr {
|
||||
kind: ExprKind::Variable("a".to_string()),
|
||||
kind: ExprKind::Variable("a".to_owned()),
|
||||
span: 5..6,
|
||||
}),
|
||||
rhs: Box::new(Expr {
|
||||
|
@ -594,7 +594,7 @@ mod tests {
|
|||
let expected = &[Stmt {
|
||||
kind: StmtKind::Var {
|
||||
iden: Iden {
|
||||
iden: "a".to_string(),
|
||||
iden: "a".to_owned(),
|
||||
span: 4..5,
|
||||
},
|
||||
init: Some(Expr {
|
||||
|
@ -631,7 +631,7 @@ mod tests {
|
|||
body: Block {
|
||||
block: vec![Stmt {
|
||||
kind: StmtKind::Print(Expr {
|
||||
kind: ExprKind::Literal(Value::Str("Buy Able products!".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("Buy Able products!".to_owned())),
|
||||
span: 19..39,
|
||||
}),
|
||||
span: 19..46,
|
||||
|
@ -651,17 +651,17 @@ mod tests {
|
|||
let expected = &[Stmt {
|
||||
kind: StmtKind::Var {
|
||||
iden: Iden {
|
||||
iden: "script".to_string(),
|
||||
iden: "script".to_owned(),
|
||||
span: 13..17,
|
||||
},
|
||||
init: Some(Expr {
|
||||
kind: ExprKind::BinOp {
|
||||
lhs: Box::new(Expr {
|
||||
kind: ExprKind::Literal(Value::Str("script".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("script".to_owned())),
|
||||
span: 20..26,
|
||||
}),
|
||||
rhs: Box::new(Expr {
|
||||
kind: ExprKind::Variable("script".to_string()),
|
||||
kind: ExprKind::Variable("script".to_owned()),
|
||||
span: 29..33,
|
||||
}),
|
||||
kind: BinOpKind::Add,
|
||||
|
@ -684,7 +684,7 @@ mod tests {
|
|||
kind: ExprKind::Cart(vec![
|
||||
(
|
||||
Expr {
|
||||
kind: ExprKind::Literal(Value::Str("able".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("able".to_owned())),
|
||||
span: 1..7,
|
||||
},
|
||||
Expr {
|
||||
|
@ -694,7 +694,7 @@ mod tests {
|
|||
),
|
||||
(
|
||||
Expr {
|
||||
kind: ExprKind::Literal(Value::Str("script".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("script".to_owned())),
|
||||
span: 14..22,
|
||||
},
|
||||
Expr {
|
||||
|
@ -731,11 +731,11 @@ mod tests {
|
|||
expr: Box::new(Expr {
|
||||
kind: ExprKind::Cart(vec![(
|
||||
Expr {
|
||||
kind: ExprKind::Literal(Value::Str("able".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("able".to_owned())),
|
||||
span: 1..7,
|
||||
},
|
||||
Expr {
|
||||
kind: ExprKind::Literal(Value::Str("ablecorp".to_string())),
|
||||
kind: ExprKind::Literal(Value::Str("ablecorp".to_owned())),
|
||||
span: 11..21,
|
||||
},
|
||||
)]),
|
||||
|
|
|
@ -113,7 +113,7 @@ impl Value {
|
|||
}
|
||||
}
|
||||
|
||||
/// Coerce a Value to a boolean. The conversion cannot fail.
|
||||
/// Coerce a value to a boolean.
|
||||
pub fn into_bool(self) -> bool {
|
||||
match self {
|
||||
Value::Abool(b) => b.into(),
|
||||
|
@ -130,7 +130,7 @@ impl Value {
|
|||
}
|
||||
}
|
||||
|
||||
/// Coerce a Value to an aboolean
|
||||
/// Coerce a value to an aboolean.
|
||||
pub fn into_abool(self) -> Abool {
|
||||
match self {
|
||||
Value::Nul => Abool::Never,
|
||||
|
@ -170,7 +170,7 @@ impl Value {
|
|||
}
|
||||
}
|
||||
|
||||
/// Coerce a Value to a functio
|
||||
/// Coerce a value to a functio.
|
||||
pub fn into_functio(self) -> Functio {
|
||||
match self {
|
||||
Value::Nul => Functio::AbleFunctio {
|
||||
|
@ -186,6 +186,7 @@ impl Value {
|
|||
}
|
||||
}
|
||||
|
||||
/// Coerce a value into a cart.
|
||||
pub fn into_cart(self) -> Cart {
|
||||
match self {
|
||||
Value::Nul => HashMap::new(),
|
||||
|
|
Loading…
Reference in a new issue