Private lifetime inference

TBH, getting lifetime bounds right is rarely the noisy part. I think it'd be entirely fine to solve that part like we solve -> _: with a structured suggestion inferred from the body.

Then I agree with the mention of a macro fn: then it could potentially even just be

macro fn find_best(primary, fallback) {
    if primary.is_valid() { &primary.summary } else { &fallback.summary }
}

where not only do I not need to put in the lifetimes but I can even leave off the types and have it just happen in the context of the caller instead.

Which would, among other things, be really really useful for math where writing out all the num_traits bounds is particularly annoying for a small helper.

7 Likes