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:
thread::scoped
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?
JoinGuard
#[must_use]
twenty characters
It is already must_use:
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.)
#[must_use = "code will not run in parallel if
is immediately dropped"]
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!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.