Guest User

Untitled

a guest
Dec 15th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. struct Circle {x: f64, y: f64, radius: f64}
  2.  
  3. trait HasArea {
  4. fn area(&self) -> f64;
  5. }
  6.  
  7. impl HasArea for Circle {
  8. fn area(&self) -> f64 {
  9. std::f64::consts::PI * (self.radius * self.radius)
  10. }
  11. }
  12.  
  13.  
  14. fn main() {
  15. let c = Circle{x: 12.0, y: 34.0, radius: 56.0};
  16. println!("Fläche = {}", c.area())
  17. }
Add Comment
Please, Sign In to add comment