diff --git a/samples/philosophers/src/channel.rs b/samples/philosophers/src/channel.rs index 82781201..f76964f2 100644 --- a/samples/philosophers/src/channel.rs +++ b/samples/philosophers/src/channel.rs @@ -32,8 +32,10 @@ enum Command { } /// This implements a single Fork on the server side for the ChannelSync. +#[derive(Default)] enum ChannelFork { /// The fork is free, + #[default] Free, /// The work is in use, nobody is waiting. InUse, @@ -41,12 +43,6 @@ enum ChannelFork { InUseWait(Sender<()>), } -impl Default for ChannelFork { - fn default() -> Self { - ChannelFork::Free - } -} - impl ChannelFork { /// Attempt to aquire the work. If it is free, reply to the sender, otherwise, track them to /// reply to them when the fork is freed up. diff --git a/samples/philosophers/src/dynsemsync.rs b/samples/philosophers/src/dynsemsync.rs index 74b6f1ee..9f43c0b6 100644 --- a/samples/philosophers/src/dynsemsync.rs +++ b/samples/philosophers/src/dynsemsync.rs @@ -37,7 +37,7 @@ pub fn dyn_semaphore_sync() -> Vec> { .each_ref() .map(|()| Arc::new(Semaphore::new(1, 1).unwrap())); - let syncers = (0..NUM_PHIL) + (0..NUM_PHIL) .map(|_| { let syncer = SemSync { forks: forks.clone(), @@ -45,7 +45,5 @@ pub fn dyn_semaphore_sync() -> Vec> { let item = Box::new(syncer) as Box; Arc::from(item) }) - .collect(); - - syncers + .collect() } diff --git a/samples/philosophers/src/semsync.rs b/samples/philosophers/src/semsync.rs index 0cf901df..c8896fe1 100644 --- a/samples/philosophers/src/semsync.rs +++ b/samples/philosophers/src/semsync.rs @@ -38,7 +38,7 @@ pub fn semaphore_sync() -> Vec> { Arc::new(m.init_once((1, 1)).unwrap()) }); - let syncers = (0..NUM_PHIL) + (0..NUM_PHIL) .map(|_| { let syncer = SemSync { forks: forks.clone(), @@ -46,9 +46,7 @@ pub fn semaphore_sync() -> Vec> { let item = Box::new(syncer) as Box; Arc::from(item) }) - .collect(); - - syncers + .collect() } kobj_define! {