loc: loc
to use equivalent shorthand syntax: loc
59 kind: InstructionKind::Push(Value::Str(
60 loc.0.clone() + ":" + &loc.1.to_string() + ":" + &loc.2.to_string(),
61 )),
62 loc: loc, 63 ip: instruction.ip,
64 };
65 }
In struct
/enum
initializations, if the field and variable have the same
name, the field name is redundant and shorthand syntax is applicable.
Use field initialization shorthand.
struct Foo {
a: u32,
b: u32
}
let a = 20;
let b = 5;
let foo = Foo {
a: a, // this field name is redundant
b: b
};
// the last line can be simplified to
let foo = Foo { a, b };