2015-01-04から1日間の記事一覧
Generics の restriction に複数の trait を指定したい場合、+ を使えばいいらしい。 struct Circle { x: f64, y: f64, radius: f64, } trait HasArea { fn area(&self) -> f64; } trait HasPoint { fn point(&self) -> (f64, f64); } impl HasArea for Circ…
Generics の restriction に複数の trait を指定したい場合、+ を使えばいいらしい。 struct Circle { x: f64, y: f64, radius: f64, } trait HasArea { fn area(&self) -> f64; } trait HasPoint { fn point(&self) -> (f64, f64); } impl HasArea for Circ…