SHARE
TWEET

Untitled

a guest Aug 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top