|
Esteban K 🦀⚙️
@ekuber
|
26. sij |
|
Even better if you can also show me the road you took to reach the understanding that HKLT 1) were a thing and 2) you needed to use them.
|
||
|
|
||
|
Félix Fischer
@FelixFischer91
|
26. sij |
|
Wait, what *are* HKLT? Can you point me to some resources? They sound mightily interesting.
|
||
|
|
||
|
Esteban K 🦀⚙️
@ekuber
|
26. sij |
|
doc.rust-lang.org/reference/trai…
doc.rust-lang.org/nomicon/hrtb.h…
stackoverflow.com/questions/3559…
It's the `for<'a> fn(&'a T) -> &'a K` syntax, so that you can pass around closures that have borrows that are related to its inputs, but detached to the current Item context.
|
||
|
|
||
|
Manish
@ManishEarth
|
26. sij |
|
i don't have examples on me but in stylo we almost needed them due to a lack of GATs with lifetimes (you can hack it with for<'a> Trait<'a>)
|
||
|
|
||
|
Esteban K 🦀⚙️
@ekuber
|
26. sij |
|
That is precisely the kind of out of the left field use I want to hear about!
|
||
|
|
||
|
David Tolnay
@davidtolnay
|
26. sij |
|
I think you are asking about higher *ranked*, not higher *kinded* which are a different thing.
Primer: stephanboyer.com/post/115/highe…
|
||
|
|
||
|
David Tolnay
@davidtolnay
|
26. sij |
|
Higher kinded would be a lifetime from lifetimes to lifetimes (??). Higher ranked would be a "for any" lifetime.
|
||
|
|
||
|
David Barsky
@endsofthreads
|
26. sij |
|
We needed them in `tracing` (github.com/tokio-rs/traci…), especially the `LookupSpan` bounds.
I don't recall _why_ we ended up needing them; I think @mycoliza short-circuited that search process for me.
|
||
|
|
||
|
electronic liza
@mycoliza
|
26. sij |
|
the trait methods return a struct with a reference to the receiver in it; we need HRTB so that we can bound a generic type parameter with that trait without also being generic over the lifetime
|
||
|
|
||
|
Tyler Mandry
@tmandry
|
27. sij |
|
IME, it’s most frequently used for function pointers and Fn* bounds
|
||
|
|
||
|
o0Ignition0o
@o0ignition0o
|
27. sij |
|
I read it Fn starbound and it just made my day. pic.twitter.com/IWjpjokeRC
|
||
|
|
||