Skip to content

Commit 1d5824a

Browse files
authored
chore: fix clippy complaints from Rust 1.89.0 (#277)
Signed-off-by: Ivan Babrou <[email protected]>
1 parent cd3c3e8 commit 1d5824a

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/encoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'a> From<protobuf::LabelSetEncoder<'a>> for LabelSetEncoder<'a> {
232232

233233
impl LabelSetEncoder<'_> {
234234
/// Encode the given label.
235-
pub fn encode_label(&mut self) -> LabelEncoder {
235+
pub fn encode_label(&mut self) -> LabelEncoder<'_> {
236236
for_both_mut!(self, LabelSetEncoderInner, e, e.encode_label().into())
237237
}
238238
}
@@ -321,7 +321,7 @@ impl<'a> From<protobuf::LabelEncoder<'a>> for LabelEncoder<'a> {
321321

322322
impl LabelEncoder<'_> {
323323
/// Encode a label.
324-
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
324+
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder<'_>, std::fmt::Error> {
325325
for_both_mut!(
326326
self,
327327
LabelEncoderInner,

src/encoding/protobuf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub(crate) struct DescriptorEncoder<'a> {
7272
impl DescriptorEncoder<'_> {
7373
pub(crate) fn new(
7474
metric_families: &mut Vec<openmetrics_data_model::MetricFamily>,
75-
) -> DescriptorEncoder {
75+
) -> DescriptorEncoder<'_> {
7676
DescriptorEncoder {
7777
metric_families,
7878
prefix: Default::default(),
@@ -232,7 +232,7 @@ impl MetricEncoder<'_> {
232232
pub fn encode_family<S: EncodeLabelSet>(
233233
&mut self,
234234
label_set: &S,
235-
) -> Result<MetricEncoder, std::fmt::Error> {
235+
) -> Result<MetricEncoder<'_>, std::fmt::Error> {
236236
let mut labels = self.labels.clone();
237237
label_set.encode(
238238
&mut LabelSetEncoder {
@@ -382,7 +382,7 @@ pub(crate) struct LabelSetEncoder<'a> {
382382
}
383383

384384
impl LabelSetEncoder<'_> {
385-
pub fn encode_label(&mut self) -> LabelEncoder {
385+
pub fn encode_label(&mut self) -> LabelEncoder<'_> {
386386
LabelEncoder {
387387
labels: self.labels,
388388
}
@@ -395,7 +395,7 @@ pub(crate) struct LabelEncoder<'a> {
395395
}
396396

397397
impl LabelEncoder<'_> {
398-
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
398+
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder<'_>, std::fmt::Error> {
399399
self.labels.push(openmetrics_data_model::Label::default());
400400

401401
Ok(LabelKeyEncoder {

src/encoding/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl std::fmt::Debug for DescriptorEncoder<'_> {
195195
}
196196

197197
impl DescriptorEncoder<'_> {
198-
pub(crate) fn new(writer: &mut dyn Write) -> DescriptorEncoder {
198+
pub(crate) fn new(writer: &mut dyn Write) -> DescriptorEncoder<'_> {
199199
DescriptorEncoder {
200200
writer,
201201
prefix: Default::default(),
@@ -643,7 +643,7 @@ impl<'a> LabelSetEncoder<'a> {
643643
}
644644
}
645645

646-
pub fn encode_label(&mut self) -> LabelEncoder {
646+
pub fn encode_label(&mut self) -> LabelEncoder<'_> {
647647
let first = self.first;
648648
self.first = false;
649649
LabelEncoder {
@@ -667,7 +667,7 @@ impl std::fmt::Debug for LabelEncoder<'_> {
667667
}
668668

669669
impl LabelEncoder<'_> {
670-
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
670+
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder<'_>, std::fmt::Error> {
671671
if !self.first {
672672
self.writer.write_str(",")?;
673673
}

src/metrics/exemplar.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<S, N: Clone, A: counter::Atomic<N>> CounterWithExemplar<S, N, A> {
128128

129129
/// Get the current value of the [`CounterWithExemplar`] as well as its
130130
/// [`Exemplar`] if any.
131-
pub fn get(&self) -> (N, MappedRwLockReadGuard<Option<Exemplar<S, N>>>) {
131+
pub fn get(&self) -> (N, MappedRwLockReadGuard<'_, Option<Exemplar<S, N>>>) {
132132
let inner = self.inner.read();
133133
let value = inner.counter.get();
134134
let exemplar = RwLockReadGuard::map(inner, |inner| &inner.exemplar);
@@ -143,7 +143,7 @@ impl<S, N: Clone, A: counter::Atomic<N>> CounterWithExemplar<S, N, A> {
143143
/// The caller of this function has to uphold the property of an Open
144144
/// Metrics counter namely that the value is monotonically increasing, i.e.
145145
/// either stays the same or increases.
146-
pub fn inner(&self) -> MappedRwLockReadGuard<A> {
146+
pub fn inner(&self) -> MappedRwLockReadGuard<'_, A> {
147147
RwLockReadGuard::map(self.inner.read(), |inner| inner.counter.inner())
148148
}
149149
}
@@ -261,7 +261,7 @@ impl<S> HistogramWithExemplars<S> {
261261
}
262262
}
263263

264-
pub(crate) fn inner(&self) -> RwLockReadGuard<HistogramWithExemplarsInner<S>> {
264+
pub(crate) fn inner(&self) -> RwLockReadGuard<'_, HistogramWithExemplarsInner<S>> {
265265
self.inner.read()
266266
}
267267
}

src/metrics/family.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<S: Clone + std::hash::Hash + Eq, M, C: MetricConstructor<M>> Family<S, M, C
263263
/// NB: This method can cause deadlocks if multiple metrics within this family are read at
264264
/// once. Use [`Family::get_or_create_owned()`] if you would like to avoid this by cloning the
265265
/// metric `M`.
266-
pub fn get_or_create(&self, label_set: &S) -> MappedRwLockReadGuard<M> {
266+
pub fn get_or_create(&self, label_set: &S) -> MappedRwLockReadGuard<'_, M> {
267267
if let Some(metric) = self.get(label_set) {
268268
return metric;
269269
}
@@ -296,7 +296,7 @@ impl<S: Clone + std::hash::Hash + Eq, M, C: MetricConstructor<M>> Family<S, M, C
296296
/// metric.inc();
297297
/// };
298298
/// ```
299-
pub fn get(&self, label_set: &S) -> Option<MappedRwLockReadGuard<M>> {
299+
pub fn get(&self, label_set: &S) -> Option<MappedRwLockReadGuard<'_, M>> {
300300
RwLockReadGuard::try_map(self.metrics.read(), |metrics| metrics.get(label_set)).ok()
301301
}
302302

@@ -341,7 +341,7 @@ impl<S: Clone + std::hash::Hash + Eq, M, C: MetricConstructor<M>> Family<S, M, C
341341
self.metrics.write().clear()
342342
}
343343

344-
pub(crate) fn read(&self) -> RwLockReadGuard<HashMap<S, M>> {
344+
pub(crate) fn read(&self) -> RwLockReadGuard<'_, HashMap<S, M>> {
345345
self.metrics.read()
346346
}
347347
}

src/metrics/histogram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Histogram {
106106
}
107107
}
108108

109-
pub(crate) fn get(&self) -> (f64, u64, MappedRwLockReadGuard<Vec<(f64, u64)>>) {
109+
pub(crate) fn get(&self) -> (f64, u64, MappedRwLockReadGuard<'_, Vec<(f64, u64)>>) {
110110
let inner = self.inner.read();
111111
let sum = inner.sum;
112112
let count = inner.count;

0 commit comments

Comments
 (0)