Advertisement
Guest User

Untitled

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