Can we reduce the amount of code further?

Yes. It is possible to completely omit the requirement to create an implementation of a trait if that trait contains a default method:

trait MyTrait 
{
fn test_code(&self) -> bool;
fn self_test_code(&self) -> bool { self.test_code() } }

test_code is just the stub which requires an implementation. The self_test_code function doesn't need an implementation as it has a default method already.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset