Impl for Struct that uses Generics and associated methods that doesn't use the generic

⚓ Rust    📅 2025-11-18    👤 surdeus    👁️ 11      

surdeus

So I have a struct like this which uses a generic.

image

Then I have an impl block like this
image

I have added a method to the struct that does not use the generic at all.
image

But my linter tells me I still have to specify the generic field when calling this method through my struct. So it ends up looking something like this.
image

Is there any way I can still have the function associated with the struct without having to specify the generic like this in the function call? I would like it to look like Matrix::permutations(&numbers); instead of Matrix::<f32>::permutations(&numbers).

10 posts - 4 participants

Read full topic

🏷️ Rust_feed