Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Circle {x: f64, y: f64, radius: f64}
- trait HasArea {
- fn area(&self) -> f64;
- }
- impl HasArea for Circle {
- fn area(&self) -> f64 {
- std::f64::consts::PI * (self.radius * self.radius)
- }
- }
- fn main() {
- let c = Circle{x: 12.0, y: 34.0, radius: 56.0};
- println!("Fläche = {}", c.area())
- }
Add Comment
Please, Sign In to add comment