In Rust it is easy to constrain a generic type to only include types extending from some interface. For example:
pub trait DoSomething {
fn do_something(&self);
}
There are three main concepts with Rust:
These are fairly simple concepts, but they are often counter-intuitive to concepts in other languages, so I wanted to give a shot at