r/rustjerk • • Oct 14 '26

Rust devs hate this one simple trick

Post image
409 Upvotes

39 comments sorted by

View all comments

131

u/renchuwang Oct 14 '26

Well since you're only defining but not using, it is actually safe!

44

u/SirKastic23 Oct 14 '26

Safe and not sound!

9

u/thisiselgun Oct 14 '26

5

u/SirKastic23 Oct 14 '26

That's the song I was thinking of too! It's a classic

25

u/uahw Oct 14 '26

I don’t think it is. I think rust especially states that two mut references aren’t allowed to exist at the same time even if on is unused

28

u/CommonNoiter Oct 14 '26

As neither are used i don't think their lifetimes overlap so they don't both exist at the same time.

16

u/simonask_ Oct 14 '26

Saved by the NLL.