Should JoinGuard be must_use?


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!

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

1 Like

:+1: twenty characters


It is already must_use:


(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.)


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!

closed #6

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.