I've been working on a Rust project with a friend and I swear he's the best tester for compiler error messages. Today, when he wanted to add a generic type to an enum that already had a lifetime, he wrote:
enum Foo<'a><T> { ... }
The compiler was not ready for this case! 😂 /1
Conversation
`<A: Lifetime, ...>` 🙃🙃
1
1
it makes even more sense when we stop talking about "lifetimes" and more about "origins" like in ' talk from last year
because what's important to track is how a borrow was created, everything else derives from it
if you think about it... that could include Box<T>!
3
1
4
Hmmmm I want to steal some of these ideas.... 🤔🤔🤔
struct Foo<T> {
data: &[T],
count: &mut usize,
next: Option<&mut Foo<T>>,
}
// automatically transformed to:
struct Foo<'a, 'b, 'c, T> {
data: &'a [T],
count: &'b mut usize,
next: Option<&'c mut Foo<'a, 'b, 'c, T>>,
}
then you just infer fn signatures!
1
1


