A valid use case for a `method is not a member of trait`?


#1

While implementing a Trait method (lets say method1) for a given type, I would like to split the code into multiple methods (it makes sense from the logic of the program). The natural way (to me at least) is to put all these helper functions into the same impl block as they belong together with method1. But this is not allowed and upon compilation I get:

error: method method1_helper is not a member of trait This Trait`

The only way to fix it seems to be:

  1. putting all the code in the type impl block
  2. creating another trait
  3. using module functions.

None of them seem optimal, these functions really belong in the impl block. Is there a way to do this?


#2

You can put them in a separate impl block just after the impl Trait block.


#3

Note that you can have multiple impl blocks for the same struct, which allows you to group the methods logically.