r/ProgrammingLanguages • u/jamiiecb • Apr 10 '26
Borrow-checking surprises
https://www.scattered-thoughts.net/writing/borrow-checking-surprises
52
Upvotes
r/ProgrammingLanguages • u/jamiiecb • Apr 10 '26
View all comments
18
u/iBPsThrowingObject Apr 10 '26
Those are less "borrow checking surprises" and more of "ergonomic accommodations that slightly break the basic mental model". In fact, the post itself points this out at the very if you unroll all the spoilers:
There's a big one with non-lexical lifetimes. The Book at first tells you that values are block-scoped, and you might be a bit surprised when this compiles:
And then you may see this work and think you got it:
and be stumped once again when this refuses to compile: