This simple trait fails to compile:
pub trait Foo<T> {
const FOO: &'static fn(T);
}
error[E0310]: the parameter type `T` may not live long enough
--> src/lib.rs:3:5
|
2 | pub trait Foo<T> {
| - help: consider adding an explicit lifetime bound `T: 'static`...
3 | const FOO: &'static fn(T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...so that the reference type `&'static fn(T)` does not outlive the data it points at
--> src/lib.rs:3:5
|
3 | const FOO: &'static fn(T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0310`.
However, T's lifetime obviously has nothing to do with the lifetime of a pointer to a function that includes T.
This simple trait fails to compile:
However,
T's lifetime obviously has nothing to do with the lifetime of a pointer to a function that includesT.