Should JoinGuard be must_use?


#1

I’ve seen the same problem with using thread::scoped show up on IRC, Stack Overflow, even in the docs! The problem? Inserting a semicolon at the end of the call:

let guards: Vec<_> = (0..3).map(|_| {
    thread::scoped(|| {}); // Oh no!
}).collect();

sellibitze suggested that JoinGuard should be marked as #[must_use] - what do people think about this change?


#2

:+1: twenty characters


#3

It is already must_use:


#4

(I suppose we should use must_use's optional message to provide more info, e.g. #[must_use = "code will not run in parallel ifJoinGuardis immediately dropped"]. The exact text could be better than my scratch example.)


#5

Wow. Now what I want to know is why I didn’t look for that first, or notice those warnings when helping people. Sigh.

I think I might just do that. Thanks!