rust/tests/ui/confuse-field-and-method/private-field.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
378 B
Rust
Raw Normal View History

pub mod animal {
pub struct Dog {
pub age: usize,
dog_age: usize,
}
impl Dog {
pub fn new(age: usize) -> Dog {
Dog { age: age, dog_age: age * 7 }
}
}
}
fn main() {
let dog = animal::Dog::new(3);
2017-11-20 06:13:27 -06:00
let dog_age = dog.dog_age(); //~ ERROR no method
//let dog_age = dog.dog_age;
println!("{}", dog_age);
}