From 0b6a4634675f27b88bb61b54f2b3711d0cd2f1a0 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Mon, 3 May 2021 08:20:40 +0200 Subject: Revert "Make runnable's run() method take a mutable self-reference." This reverts commit e1f0525e4e1dcf674aa7489042a06b7c7d671a2a. I've decided against having mutable self-references. It's a bit less convenient, but more sane. Also, the revert can be reverted any time, should the need arise. --- clock/src/lib.rs | 2 +- pulse/src/runnable/mod.rs | 2 +- swaystatus-plugin/src/lib.rs | 2 +- swaystatus/src/main.rs | 2 +- swaystatus/src/test_plugin.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clock/src/lib.rs b/clock/src/lib.rs index 8055449..76f5ea7 100644 --- a/clock/src/lib.rs +++ b/clock/src/lib.rs @@ -76,7 +76,7 @@ impl<'c> ClockRunnable<'c> { } impl<'c> SwayStatusModuleRunnable for ClockRunnable<'c> { - fn run(&mut self) { + fn run(&self) { match self.config.refresh_rate { ClockRefreshRate::NotSynchronized { seconds } => { self.simple_loop(std::time::Duration::from_secs_f32(seconds.abs())); diff --git a/pulse/src/runnable/mod.rs b/pulse/src/runnable/mod.rs index ca63f24..612bca9 100644 --- a/pulse/src/runnable/mod.rs +++ b/pulse/src/runnable/mod.rs @@ -28,7 +28,7 @@ impl<'p : 's, 's> PulseVolumeRunnable<'p> { } impl<'p> SwayStatusModuleRunnable for PulseVolumeRunnable<'p> { - fn run(&mut self) { + fn run(&self) { //TODO } } diff --git a/swaystatus-plugin/src/lib.rs b/swaystatus-plugin/src/lib.rs index a9859c8..8a632cf 100644 --- a/swaystatus-plugin/src/lib.rs +++ b/swaystatus-plugin/src/lib.rs @@ -156,7 +156,7 @@ pub trait SwayStatusModule { ///Will be called in a worker thread. pub trait SwayStatusModuleRunnable : Send { ///Starts executing this module. - fn run(&mut self); + fn run(&self); } ///Implement this trait on a struct that holds the configuration for a single instance of your diff --git a/swaystatus/src/main.rs b/swaystatus/src/main.rs index c1c1b73..e4847d9 100644 --- a/swaystatus/src/main.rs +++ b/swaystatus/src/main.rs @@ -89,7 +89,7 @@ fn core_loop(plugin_path : &std::path::Path, config_path : &std::path::Path) -> // Main everything is ready for the big main loop. Let's spawn the threads! if let Err(_e) = thread::scope(|s| { signalhandler::handle_signals(s, sender_from_plugins); - for mut runnable in runnables { + for runnable in runnables { s.spawn(move |_| { runnable.run(); }); diff --git a/swaystatus/src/test_plugin.rs b/swaystatus/src/test_plugin.rs index c82366d..4e265e2 100644 --- a/swaystatus/src/test_plugin.rs +++ b/swaystatus/src/test_plugin.rs @@ -28,7 +28,7 @@ pub struct TestConfig { } impl SwayStatusModuleRunnable for TestRunnable { - fn run(&mut self) { + fn run(&self) { println!("Running!"); } } -- cgit v1.2.3