I'm responding so future readers see the answer, because oooh boy am I not engaging with this account.
The curly braces shortens the lifespan of the `MutexGuard` so it gets unlocked before the body of the if-statement. Normally, the temporary used in the if-let pattern lives until the end of the if-statement.
This wouldn't compile if the value guarded by the Mutex wasn't trivially copyable, but it is.
(Note how none of this is UB, just a particularly contrived way to introduce a deadlock.)
The curly braces shortens the lifespan of the `MutexGuard` so it gets unlocked before the body of the if-statement. Normally, the temporary used in the if-let pattern lives until the end of the if-statement.
This wouldn't compile if the value guarded by the Mutex wasn't trivially copyable, but it is.
(Note how none of this is UB, just a particularly contrived way to introduce a deadlock.)