I have function that is part of a struct (for context reasons) which does not take the self
parameter. Furthermore, the struct itself takes a generic parameter T
with some trait restrictions:
trait SomeRestriction {}
struct SomeStruct<T: SomeRestriction>(T);
impl<T: SomeRestriction> SomeStruct<T> {
fn some_function_that_does_not_take_self() -> String {
todo!()
}
}
I want to write a test and I would like to avoid giving
that function the self
parameter since mocking the object
with some generic struct parameter is a lot of effort for that small function and test.
I do it for the other tests since it is necessary there, but I would like to avoid it wherever I can.
I tried to call it like this:
let some_string = SomeStruct::some_function_that_does_not_take_self();
but it will ask me for a type annotation even though it is not needed.
Is there a way to call it without mocking the struct or removing the function from the struct implementation?