Skip to content

Commit b41f1ad

Browse files
committed
Change how checkout IDs are configured for debug only.
1 parent 05beeb8 commit b41f1ad

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/client/pool/checkout.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,33 @@ use crate::client::conn::connector::{Connector, ConnectorMeta};
1717
use crate::client::conn::Protocol;
1818
use crate::client::conn::Transport;
1919

20+
#[cfg(debug_assertions)]
21+
use self::ids::CheckoutId;
2022
use super::key::Token;
2123
use super::Config;
2224
use super::PoolRef;
2325
use super::PoolableConnection;
2426
use super::Pooled;
2527

2628
#[cfg(debug_assertions)]
27-
static CHECKOUT_ID: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(1);
29+
mod ids {
30+
use core::fmt;
2831

29-
#[cfg(debug_assertions)]
30-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31-
struct CheckoutId(usize);
32+
static CHECKOUT_ID: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(1);
3233

33-
#[cfg(debug_assertions)]
34-
impl CheckoutId {
35-
fn new() -> Self {
36-
CheckoutId(CHECKOUT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst))
34+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
35+
pub(super) struct CheckoutId(pub(super) usize);
36+
37+
impl CheckoutId {
38+
pub(super) fn new() -> Self {
39+
CheckoutId(CHECKOUT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst))
40+
}
3741
}
38-
}
3942

40-
#[cfg(debug_assertions)]
41-
impl fmt::Display for CheckoutId {
42-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43-
write!(f, "checkout-{}", self.0)
43+
impl fmt::Display for CheckoutId {
44+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45+
write!(f, "checkout-{}", self.0)
46+
}
4447
}
4548
}
4649

0 commit comments

Comments
 (0)