trait Get<'a> {}
struct Foo;
impl<'a> Get<'a> for Foo {}
fn caller_func<'a, T>(get: T)
where
T: Get<'a>,
{}
fn callee_func<T>(get: T)
where
for<'a> T: Get<'a>,
{}
When I call caller_func(Foo), what does that mean by: the caller choose the lifetime.
When I call callee_func(Foo), what does that mean by: the callee choose the lifetime.
You're probably familiar with Vec<T>, where you -- the user of Vec<T> -- can choose whatever T you need. A fn with_generics<'lifetime, Type> is similar -- and one who uses it (the caller) can choose whatever 'lifetime and Type they need.
When it comes to lifetimes, it's also important that the caller can only choose lifetimes that are at least as long as the call -- the function body can assume the lifetime is valid for the entire body (longer than any local, which all drop by the end of the function body). It's important because it means the lifetime can't be smaller than the function body -- so inside the function, it's not possible to borrow a local for the generic lifetime.
You didn't ask about this part, but in anticipation:
// Caller can pass in any implementor of Display
fn foo(d: impl Display)
is analogous to
// Caller chooses D (provided D implements Display)
fn foo<D: Display>(d: D)
While
// Function decides the single (but opaque) type that is returned
fn foo() -> impl Display
is analogous to
// Function decides the single type that is returned
fn foo() -> String