rust/tests/ui/confuse-field-and-method/private-field.rs
2023-01-11 09:32:08 +00:00

20 lines
378 B
Rust

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);
let dog_age = dog.dog_age(); //~ ERROR no method
//let dog_age = dog.dog_age;
println!("{}", dog_age);
}