From 6585afb786e4dab139986967990b521fba6878da Mon Sep 17 00:00:00 2001 From: CrLF0710 Date: Tue, 9 Apr 2019 17:05:20 +0800 Subject: [PATCH] Remove FnBox and use builtin impl FnOnce for Box instead. --- ci/dictionary.txt | 1 - src/ch20-03-graceful-shutdown-and-cleanup.md | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ci/dictionary.txt b/ci/dictionary.txt index 3a780fd7ad..a910123062 100644 --- a/ci/dictionary.txt +++ b/ci/dictionary.txt @@ -160,7 +160,6 @@ Filesystem filesystem's filesystems Firefox -FnBox FnMut FnOnce formatter diff --git a/src/ch20-03-graceful-shutdown-and-cleanup.md b/src/ch20-03-graceful-shutdown-and-cleanup.md index f36fa026ee..3a3c14f707 100644 --- a/src/ch20-03-graceful-shutdown-and-cleanup.md +++ b/src/ch20-03-graceful-shutdown-and-cleanup.md @@ -450,17 +450,7 @@ pub struct ThreadPool { sender: mpsc::Sender, } -trait FnBox { - fn call_box(self: Box); -} - -impl FnBox for F { - fn call_box(self: Box) { - (*self)() - } -} - -type Job = Box; +type Job = Box; impl ThreadPool { /// Create a new ThreadPool. @@ -536,7 +526,7 @@ impl Worker { Message::NewJob(job) => { println!("Worker {} got a job; executing.", id); - job.call_box(); + (job)(); }, Message::Terminate => { println!("Worker {} was told to terminate.", id);