Hi,
I'm trying to implement a detailed custom trait. I will have two implementations, maybe more. I need to be sure that I won't miss any of the functions for other types.
I know that I can have tests checking that, but I'd like to have this checked in the trait.
The std::ops::BitOr trait has just one function fn bitor(self, rhs: Self) -> Self.
Let's talk only about u8.
It looks like for working with references, we need to implement four different versions like (BitOr in std::ops - Rust):
impl BitOr<u8> for u8
impl<'_> BitOr<&'_ u8> for u8
impl<'a> BitOr<u8> for &'a u8
impl<'_, '_> BitOr<&'_ u8> for &'_ u8
If I make my own trait, I can only require that the implementors should implement the BitOr with:
trait Ugh:
BitOr
{}
It would be great to have this kind of reference stuff in the list of traits.
My question is: how can I ensure that the implementors of my trait will implement all four versions of the different calls with references?