I would like to declare a struct that wraps a generic type T
like this:
use std::ops::Add;
struct MyStruct<T> where T: Add<&T, Output=T> {
t: T
}
This fails with:
error[E0637]: `&` without an explicit lifetime name cannot be used here
--> src/lib.rs:3:33
|
3 | struct MyStruct<T> where T: Add<&T, Output=T> {
| ^ explicit lifetime name needed here
error[E0310]: the parameter type `T` may not live long enough
How can I tell the compiler that &T
may be a temporary variable, and therefore any lifetime is ok?
I don't want to change my struct signature to MyStruct<'a, T>
, as that makes the usage more verbose and complicated.