Guest User

Untitled

a guest
Jul 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. struct Rectangle {
  2. width: i32,
  3. height: i32,
  4. }
  5.  
  6. impl Rectangle {
  7. fn new(width: i32, height: i32) -> Rectangle {
  8. Rectangle { width, height}
  9. }
  10.  
  11. fn area(&self) -> i32 {
  12. self.width * self.height
  13. }
  14. }
  15.  
  16. fn main() {
  17. let rect = Rectangle::new(30, 50);
  18.  
  19. println!("The area of rectangle is {}.", rect.area());
  20. }
Add Comment
Please, Sign In to add comment