Skip to content

Commit f5c70c3

Browse files
committed
chore: fix clippy warnings
1 parent d9540c6 commit f5c70c3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/layer.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ where
880880
.get_mut::<OtelData>()
881881
.map(|data| self.with_started_cx(data, &|cx| cx.clone()))
882882
})
883-
.unwrap_or_else(|| OtelContext::current())
883+
.unwrap_or_else(OtelContext::current)
884884
}
885885
} else {
886886
OtelContext::default()
@@ -896,8 +896,8 @@ where
896896
/// * `dispatch` - A reference to the tracing dispatch, used to access the subscriber
897897
/// * `id` - The ID of the span to look up
898898
/// * `f` - A callback function that receives a mutable reference to the span's `OtelData`
899-
/// This callback is used to manipulate or extract information from the OpenTelemetry context
900-
/// associated with the tracing span
899+
/// This callback is used to manipulate or extract information from the OpenTelemetry context
900+
/// associated with the tracing span
901901
///
902902
fn get_context(dispatch: &tracing::Dispatch, id: &span::Id, f: &mut dyn FnMut(&mut OtelData)) {
903903
let subscriber = dispatch
@@ -1315,28 +1315,32 @@ where
13151315
}) = otel_data
13161316
{
13171317
// Append busy/idle timings when enabled.
1318-
let timings = timings.and_then(|timings| {
1318+
let timings = timings.map(|timings| {
13191319
let busy_ns = Key::new("busy_ns");
13201320
let idle_ns = Key::new("idle_ns");
13211321

1322-
Some(vec![
1322+
vec![
13231323
KeyValue::new(busy_ns, timings.busy),
13241324
KeyValue::new(idle_ns, timings.idle),
1325-
])
1325+
]
13261326
});
13271327

13281328
if let Some(builder) = builder {
13291329
// Don't create the context here just to get a SpanRef since it's costly
13301330
let mut span = builder.start_with_context(&self.tracer, &parent_cx);
1331-
timings.map(|timings| span.set_attributes(timings));
1331+
if let Some(timings) = timings {
1332+
span.set_attributes(timings)
1333+
};
13321334
if let Some(end_time) = end_time {
13331335
span.end_with_timestamp(end_time);
13341336
} else {
13351337
span.end();
13361338
}
13371339
} else {
13381340
let span = parent_cx.span();
1339-
timings.map(|timings| span.set_attributes(timings));
1341+
if let Some(timings) = timings {
1342+
span.set_attributes(timings)
1343+
};
13401344
end_time.map_or_else(|| span.end(), |end_time| span.end_with_timestamp(end_time));
13411345
};
13421346
}

0 commit comments

Comments
 (0)