Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<'a> From<protobuf::LabelSetEncoder<'a>> for LabelSetEncoder<'a> {

impl LabelSetEncoder<'_> {
/// Encode the given label.
pub fn encode_label(&mut self) -> LabelEncoder {
pub fn encode_label(&mut self) -> LabelEncoder<'_> {
for_both_mut!(self, LabelSetEncoderInner, e, e.encode_label().into())
}
}
Expand Down Expand Up @@ -321,7 +321,7 @@ impl<'a> From<protobuf::LabelEncoder<'a>> for LabelEncoder<'a> {

impl LabelEncoder<'_> {
/// Encode a label.
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder<'_>, std::fmt::Error> {
for_both_mut!(
self,
LabelEncoderInner,
Expand Down
8 changes: 4 additions & 4 deletions src/encoding/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) struct DescriptorEncoder<'a> {
impl DescriptorEncoder<'_> {
pub(crate) fn new(
metric_families: &mut Vec<openmetrics_data_model::MetricFamily>,
) -> DescriptorEncoder {
) -> DescriptorEncoder<'_> {
DescriptorEncoder {
metric_families,
prefix: Default::default(),
Expand Down Expand Up @@ -232,7 +232,7 @@ impl MetricEncoder<'_> {
pub fn encode_family<S: EncodeLabelSet>(
&mut self,
label_set: &S,
) -> Result<MetricEncoder, std::fmt::Error> {
) -> Result<MetricEncoder<'_>, std::fmt::Error> {
let mut labels = self.labels.clone();
label_set.encode(
&mut LabelSetEncoder {
Expand Down Expand Up @@ -382,7 +382,7 @@ pub(crate) struct LabelSetEncoder<'a> {
}

impl LabelSetEncoder<'_> {
pub fn encode_label(&mut self) -> LabelEncoder {
pub fn encode_label(&mut self) -> LabelEncoder<'_> {
LabelEncoder {
labels: self.labels,
}
Expand All @@ -395,7 +395,7 @@ pub(crate) struct LabelEncoder<'a> {
}

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

Ok(LabelKeyEncoder {
Expand Down
6 changes: 3 additions & 3 deletions src/encoding/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl std::fmt::Debug for DescriptorEncoder<'_> {
}

impl DescriptorEncoder<'_> {
pub(crate) fn new(writer: &mut dyn Write) -> DescriptorEncoder {
pub(crate) fn new(writer: &mut dyn Write) -> DescriptorEncoder<'_> {
DescriptorEncoder {
writer,
prefix: Default::default(),
Expand Down Expand Up @@ -643,7 +643,7 @@ impl<'a> LabelSetEncoder<'a> {
}
}

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

impl LabelEncoder<'_> {
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder<'_>, std::fmt::Error> {
if !self.first {
self.writer.write_str(",")?;
}
Expand Down
6 changes: 3 additions & 3 deletions src/metrics/exemplar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<S, N: Clone, A: counter::Atomic<N>> CounterWithExemplar<S, N, A> {

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

pub(crate) fn inner(&self) -> RwLockReadGuard<HistogramWithExemplarsInner<S>> {
pub(crate) fn inner(&self) -> RwLockReadGuard<'_, HistogramWithExemplarsInner<S>> {
self.inner.read()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/metrics/family.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<S: Clone + std::hash::Hash + Eq, M, C: MetricConstructor<M>> Family<S, M, C
/// NB: This method can cause deadlocks if multiple metrics within this family are read at
/// once. Use [`Family::get_or_create_owned()`] if you would like to avoid this by cloning the
/// metric `M`.
pub fn get_or_create(&self, label_set: &S) -> MappedRwLockReadGuard<M> {
pub fn get_or_create(&self, label_set: &S) -> MappedRwLockReadGuard<'_, M> {
if let Some(metric) = self.get(label_set) {
return metric;
}
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<S: Clone + std::hash::Hash + Eq, M, C: MetricConstructor<M>> Family<S, M, C
/// metric.inc();
/// };
/// ```
pub fn get(&self, label_set: &S) -> Option<MappedRwLockReadGuard<M>> {
pub fn get(&self, label_set: &S) -> Option<MappedRwLockReadGuard<'_, M>> {
RwLockReadGuard::try_map(self.metrics.read(), |metrics| metrics.get(label_set)).ok()
}

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

pub(crate) fn read(&self) -> RwLockReadGuard<HashMap<S, M>> {
pub(crate) fn read(&self) -> RwLockReadGuard<'_, HashMap<S, M>> {
self.metrics.read()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Histogram {
}
}

pub(crate) fn get(&self) -> (f64, u64, MappedRwLockReadGuard<Vec<(f64, u64)>>) {
pub(crate) fn get(&self) -> (f64, u64, MappedRwLockReadGuard<'_, Vec<(f64, u64)>>) {
let inner = self.inner.read();
let sum = inner.sum;
let count = inner.count;
Expand Down
Loading