From 40fe32089eaee76887e7d2f9ce2339bc0b576c4a Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Fri, 19 Jan 2024 15:19:31 -0500 Subject: [PATCH 1/2] Switched to Into> for parameters in Builder --- bb8/src/api.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bb8/src/api.rs b/bb8/src/api.rs index 4db833c..1d0ad47 100644 --- a/bb8/src/api.rs +++ b/bb8/src/api.rs @@ -165,8 +165,11 @@ impl Builder { /// /// Defaults to None. #[must_use] - pub fn min_idle(mut self, min_idle: Option) -> Self { - self.min_idle = min_idle; + pub fn min_idle(mut self, min_idle: U) -> Self + where + U: Into>, + { + self.min_idle = min_idle.into(); self } @@ -194,7 +197,11 @@ impl Builder { /// /// Will panic if `max_lifetime` is 0. #[must_use] - pub fn max_lifetime(mut self, max_lifetime: Option) -> Self { + pub fn max_lifetime(mut self, max_lifetime: D) -> Self + where + D: Into>, + { + let max_lifetime = max_lifetime.into(); assert_ne!( max_lifetime, Some(Duration::from_secs(0)), @@ -215,7 +222,11 @@ impl Builder { /// /// Will panic if `idle_timeout` is 0. #[must_use] - pub fn idle_timeout(mut self, idle_timeout: Option) -> Self { + pub fn idle_timeout(mut self, idle_timeout: D) -> Self + where + D: Into>, + { + let idle_timeout = idle_timeout.into(); assert_ne!( idle_timeout, Some(Duration::from_secs(0)), From 9997546ba8be9dc3cdb7730c8801d500dd05080c Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Sat, 20 Jan 2024 09:02:49 -0500 Subject: [PATCH 2/2] Changed to 'impl Into>' --- bb8/src/api.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/bb8/src/api.rs b/bb8/src/api.rs index 1d0ad47..548fd04 100644 --- a/bb8/src/api.rs +++ b/bb8/src/api.rs @@ -165,10 +165,7 @@ impl Builder { /// /// Defaults to None. #[must_use] - pub fn min_idle(mut self, min_idle: U) -> Self - where - U: Into>, - { + pub fn min_idle(mut self, min_idle: impl Into>) -> Self { self.min_idle = min_idle.into(); self } @@ -197,10 +194,7 @@ impl Builder { /// /// Will panic if `max_lifetime` is 0. #[must_use] - pub fn max_lifetime(mut self, max_lifetime: D) -> Self - where - D: Into>, - { + pub fn max_lifetime(mut self, max_lifetime: impl Into>) -> Self { let max_lifetime = max_lifetime.into(); assert_ne!( max_lifetime, @@ -222,10 +216,7 @@ impl Builder { /// /// Will panic if `idle_timeout` is 0. #[must_use] - pub fn idle_timeout(mut self, idle_timeout: D) -> Self - where - D: Into>, - { + pub fn idle_timeout(mut self, idle_timeout: impl Into>) -> Self { let idle_timeout = idle_timeout.into(); assert_ne!( idle_timeout,