I know that I can have functions accept only types that implement a given trait. For example, I can
fn f<T>()
where
T: MyTrait,
{
// Super useful stuff
}
What if I wanted to implement a function that accepts anything that does not implement a given trait? For example, say that I have some computation that either:
- Requires some known, lengthy preprocessing, or
- Has a specific way of short-cutting through that preprocessing.
What I would like to do is something like:
fn preprocess<T>(computation: &mut T)
where
T: !Shortcut,
{
// Carry out the expensive precomputation.
}
I tried figuring out how to work around this problem, but I don't seem to be able to figure out any solution.