Skip to content

Commit

Permalink
Switched to Into<Option<T>> for parameters in Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Jan 19, 2024
1 parent aa46db8 commit 40fe320
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions bb8/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ impl<M: ManageConnection> Builder<M> {
///
/// Defaults to None.
#[must_use]
pub fn min_idle(mut self, min_idle: Option<u32>) -> Self {
self.min_idle = min_idle;
pub fn min_idle<U>(mut self, min_idle: U) -> Self
where
U: Into<Option<u32>>,
{
self.min_idle = min_idle.into();
self
}

Expand Down Expand Up @@ -194,7 +197,11 @@ impl<M: ManageConnection> Builder<M> {
///
/// Will panic if `max_lifetime` is 0.
#[must_use]
pub fn max_lifetime(mut self, max_lifetime: Option<Duration>) -> Self {
pub fn max_lifetime<D>(mut self, max_lifetime: D) -> Self
where
D: Into<Option<Duration>>,
{
let max_lifetime = max_lifetime.into();
assert_ne!(
max_lifetime,
Some(Duration::from_secs(0)),
Expand All @@ -215,7 +222,11 @@ impl<M: ManageConnection> Builder<M> {
///
/// Will panic if `idle_timeout` is 0.
#[must_use]
pub fn idle_timeout(mut self, idle_timeout: Option<Duration>) -> Self {
pub fn idle_timeout<D>(mut self, idle_timeout: D) -> Self
where
D: Into<Option<Duration>>,
{
let idle_timeout = idle_timeout.into();

Check warning on line 229 in bb8/src/api.rs

View check run for this annotation

Codecov / codecov/patch

bb8/src/api.rs#L225-L229

Added lines #L225 - L229 were not covered by tests
assert_ne!(
idle_timeout,
Some(Duration::from_secs(0)),
Expand Down

0 comments on commit 40fe320

Please sign in to comment.