Skip to content

Commit d31f360

Browse files
committed
Properly cfg the max field of Limit
1 parent ec3586e commit d31f360

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crates/limit/src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22
33
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
44

5+
#[cfg(feature = "tracking")]
56
use std::sync::atomic::AtomicUsize;
67

78
/// Represents a struct used to enforce a numerical limit.
89
pub struct Limit {
910
upper_bound: usize,
10-
#[allow(unused)]
11+
#[cfg(feature = "tracking")]
1112
max: AtomicUsize,
1213
}
1314

1415
impl Limit {
1516
/// Creates a new limit.
1617
#[inline]
1718
pub const fn new(upper_bound: usize) -> Self {
18-
Self { upper_bound, max: AtomicUsize::new(0) }
19+
Self {
20+
upper_bound,
21+
#[cfg(feature = "tracking")]
22+
max: AtomicUsize::new(0),
23+
}
1924
}
2025

2126
/// Creates a new limit.
2227
#[inline]
2328
#[cfg(feature = "tracking")]
2429
pub const fn new_tracking(upper_bound: usize) -> Self {
25-
Self { upper_bound, max: AtomicUsize::new(1) }
30+
Self {
31+
upper_bound,
32+
#[cfg(feature = "tracking")]
33+
max: AtomicUsize::new(1),
34+
}
2635
}
2736

2837
/// Gets the underlying numeric limit.

0 commit comments

Comments
 (0)