Задачи на ООП в Rust. Часть 9
Сделайте trait Shape с default методом fn label(&self) -> &str { "shape" }.
Дан trait:
trait Validator { fn validate(&self) -> bool; }
Реализуйте для Email и Phone struct.
Сделайте trait с required и optional (default) методами.
Используйте supertrait: trait Printable: Display { ... } (concept).
Дан trait Serializable:
trait Serializable { fn to_json(&self) -> String; }
Сделайте default impl, возвращающий "{}", и переопределите в struct.
Сделайте trait для "абстрактного" поведения без struct inheritance.
Реализуйте PartialEq вручную для struct (без derive).
Сделайте trait object невозможным для trait с generic methods — объясните почему.
Trait для default constructor pattern.
Опишите trait Shape с методом area и реализуйте его для Circle и Rectangle. Добавьте trait Drawable: Shape.