From eb6e509ad8a4148e054fd5b58f3eeba5e058cd86 Mon Sep 17 00:00:00 2001 From: Jason Volk <jason@zemos.net> Date: Sun, 4 Aug 2024 06:32:19 +0000 Subject: [PATCH] use where clause for long lines Signed-off-by: Jason Volk <jason@zemos.net> --- src/service/service.rs | 15 ++++++++++++--- src/service/services.rs | 10 ++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/service/service.rs b/src/service/service.rs index 0b9bc76c7..635f782ea 100644 --- a/src/service/service.rs +++ b/src/service/service.rs @@ -97,7 +97,10 @@ pub(crate) fn require<T: Send + Sync + 'a + 'static>(&'a self, name: &'static st /// Reference a Service by name. Panics if the Service does not exist or was /// incorrectly cast. -pub(crate) fn require<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(map: &'b Map, name: &'a str) -> Arc<T> { +pub(crate) fn require<'a, 'b, T>(map: &'b Map, name: &'a str) -> Arc<T> +where + T: Send + Sync + 'a + 'b + 'static, +{ try_get::<T>(map, name) .inspect_err(inspect_log) .expect("Failure to reference service required by another service.") @@ -109,7 +112,10 @@ pub(crate) fn require<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(map: &'b Map, /// # Panics /// Incorrect type is not a silent failure (None) as the type never has a reason /// to be incorrect. -pub(crate) fn get<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(map: &'b Map, name: &'a str) -> Option<Arc<T>> { +pub(crate) fn get<'a, 'b, T>(map: &'b Map, name: &'a str) -> Option<Arc<T>> +where + T: Send + Sync + 'a + 'b + 'static, +{ map.read() .expect("locked for reading") .get(name) @@ -123,7 +129,10 @@ pub(crate) fn get<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(map: &'b Map, name /// Reference a Service by name. Returns Err if the Service does not exist or /// was incorrectly cast. -pub(crate) fn try_get<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(map: &'b Map, name: &'a str) -> Result<Arc<T>> { +pub(crate) fn try_get<'a, 'b, T>(map: &'b Map, name: &'a str) -> Result<Arc<T>> +where + T: Send + Sync + 'a + 'b + 'static, +{ map.read() .expect("locked for reading") .get(name) diff --git a/src/service/services.rs b/src/service/services.rs index 2b9b93d45..8e69cdbb6 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -193,11 +193,17 @@ fn interrupt(&self) { } } - pub fn try_get<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(&'b self, name: &'a str) -> Result<Arc<T>> { + pub fn try_get<'a, 'b, T>(&'b self, name: &'a str) -> Result<Arc<T>> + where + T: Send + Sync + 'a + 'b + 'static, + { service::try_get::<T>(&self.service, name) } - pub fn get<'a, 'b, T: Send + Sync + 'a + 'b + 'static>(&'b self, name: &'a str) -> Option<Arc<T>> { + pub fn get<'a, 'b, T>(&'b self, name: &'a str) -> Option<Arc<T>> + where + T: Send + Sync + 'a + 'b + 'static, + { service::get::<T>(&self.service, name) } } -- GitLab