0
struct MutStr<'a, 'b> {  
  s: &'a mut &'b str 
}

I'm scratching my head trying to understand this syntax.

Thanks in advance.

I have tried looking this syntax up everywhere and cannot find anything on two lifetimes on a single struct field.

  • 5
    What's the problem? It's declaring two lifetimes, and a double reference with the outer reference having lifetime `'a` and the inner `'b`. Nothing special. – Chayim Friedman Jan 09 '23 at 16:57
  • 2
    It's a reference to a reference. Each reference has its own lifetime. – kaya3 Jan 09 '23 at 16:57
  • I see. Thank you. I thought the & was just syntax needed to define a lifetime for some reason. I didn't even realize it was a double reference! – John Caruso Jan 09 '23 at 17:22

0 Answers0