Skip to content

Commit

Permalink
Fix MSRV check for deadpool-diesel crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron authored and bikeshedder committed Sep 9, 2023
1 parent c8da07e commit a45549b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions diesel/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ pub struct Manager<C> {
pub type RecycleCheckCallback<C> = dyn Fn(&mut C) -> Result<(), Error> + Send + Sync;

/// Possible methods of how a connection is recycled.
#[derive(Default)]
pub enum RecyclingMethod<C> {
/// Only check for open transactions when recycling existing connections
/// Unless you have special needs this is a safe choice.
///
/// If the database connection is closed you will recieve an error on the first place
/// you actually try to use the connection
#[default]
Fast,
/// In addition to checking for open transactions a test query is executed
///
Expand All @@ -48,6 +46,15 @@ pub enum RecyclingMethod<C> {
CustomFunction(Box<RecycleCheckCallback<C>>),
}

// We use manual implementation here instead of `#[derive(Default)]` as of MSRV 1.63, it generates
// redundant `C: Default` bound, which imposes problems in the code.
// TODO: Use `#[derive(Default)]` with `#[default]` attribute once MSRV is bumped to 1.66 or above.
impl<C> Default for RecyclingMethod<C> {
fn default() -> Self {
Self::Fast
}
}

/// Configuration object for a Manager.
///
/// This currently only makes it possible to specify which [`RecyclingMethod`]
Expand Down

0 comments on commit a45549b

Please sign in to comment.