use std::fmt::Debug; #[derive(Debug)] struct Circle { radius:f64, } #[derive(Debug)] struct Square { side:f64, } trait Shape { fn area(&self)->f64; } impl Shape for Square{ fn area(&self)->f64{ self.side * self.side } } impl Shape for Circle{ fn area(&self)->f64{ self.radius * self.radius * std::f64::consts::PI } } //fn bilgi_ver(shape:impl Shape + Debug){ //fn bilgi_ver(shape:T){ fn bilgi_ver(shape:T) where T:Shape + Debug{ println!("{:?}",shape); println!("Alan : {}",shape.area()) } fn main() { let c = Circle{radius:3.0}; bilgi_ver(c); let s= Square{side:4.0}; bilgi_ver(s); }