mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
16 lines
270 B
Rust
16 lines
270 B
Rust
struct Thing {
|
|
x: isize
|
|
}
|
|
|
|
impl Thing {
|
|
fn mul(&self, c: &isize) -> Thing {
|
|
Thing {x: self.x * *c}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let u = Thing {x: 2};
|
|
let _v = u.mul(&3); // This is ok
|
|
let w = u * 3; //~ ERROR cannot multiply `Thing` by `{integer}`
|
|
}
|