A trait is a set of methods a type promises to provide. It is not a base class: there is no inheritance, no shared fields, and no constructor.
trait Health {
fn name(&self) -> String;
fn status(&self) -> String {
format!("{}: ok", self.name())
}
}
name is required. status has a default implementation, written in terms of the required methods — an implementor gets it for free and may override it.
