Remix.run Logo
kccqzy 3 hours ago

The HRTB is probably the trickiest syntax for specifying lifetimes. It looks like `for<'a> F: Fn(&'a (u8, u16)) -> &'a u8`.

stdatomic 3 hours ago | parent [-]

Can you translate this for those of us who don't speak rust?

Xirdus 3 hours ago | parent [-]

Type F must be a function that's generic over any possible lifetime 'a, with a single argument that's a reference with lifetime 'a to a tuple of two numbers, and returns a reference with the same lifetime 'a to an 8-bit number.

The full code is usually something like:

fn foo<F>(callback: F) where for<'a> F: ...

Which is a generic function foo that takes the argument of type F, where F must be...