2017-04-04 10:58:27 -05:00
|
|
|
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
|
2017-04-04 10:58:27 -05:00
|
|
|
//let dog_age = dog.dog_age;
|
|
|
|
println!("{}", dog_age);
|
|
|
|
}
|