When we define a trait we give it a function statement of the form fn blah(foo: Bar)
. But when implementing this trait the parameter name (here it is foo
) can be changed as you wish. So let's have an example.
/// A very simple struct
struct Simple;
/// A struct that doesn't matter
struct Whatever;
/// A trait that does something _very_ complex
trait SuperDuperComplexThing {
fn do_super_duper_complex_thing(some_extremely_and_needlessly_long_parameter: Whatever) -> Whatever ;
}
impl SuperDuperComplexThing for Simple {
fn do_super_duper_complex_thing(simple_param: Whatever) -> Whatever {
Whatever
}
}
And this works perfectly. It compiles.
Top comments (0)