mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-30 04:24:26 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			378 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			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);
 | |
| }
 | 
