Skip to content

Commit

Permalink
Update library/std/src/thread/spawnhook.rs
Browse files Browse the repository at this point in the history
Co-authored-by: waffle <waffle.lapkin@gmail.com>
  • Loading branch information
m-ou-se and WaffleLapkin authored Nov 19, 2024
1 parent 6a57559 commit 7bc457d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions library/std/src/thread/spawnhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,9 @@ pub(super) fn run_spawn_hooks(thread: &Thread) -> ChildSpawnHooks {
snapshot
});
// Iterate over the hooks, run them, and collect the results in a vector.
let mut next: &Option<Arc<SpawnHook>> = &hooks.first;
let mut to_run = Vec::new();
while let Some(hook) = next {
to_run.push((hook.hook)(thread));
next = &hook.next;
}
let to_run: Vec<_> = std::iter::successors(hooks.first.as_deref(), |hook| hook.next.as_deref())
.map(|hook| (hook.hook)(thread))
.collect();
// Pass on the snapshot of the hooks and the results to the new thread,
// which will then run SpawnHookResults::run().
ChildSpawnHooks { hooks, to_run }
Expand Down

0 comments on commit 7bc457d

Please sign in to comment.