Well, for example if you were to call t<'static>, then the method requires you to pass in a &'static String, but your string does not live forever. The syntax you are looking for is:
#[test]
fn a() {
fn t(_f: for<'a> fn(&'a String) -> &'a String) {
let s = "1".to_owned();
_f(&s);
}
}
Another question:
Docuement says, fn(T) -> U, T is contra-variant and U is covariant. And, if T == U, e.g. fn(T) -> T, It is invariant, because it is the only choice to satisfy contra-variant and covariant at the same time.
But, the following code, T == &'a String. then _f should be invariant, right?
So t should not accept x1, and compiling should fail.
However, it is compiled. Why?