From c0648c2b3c71aa75aa9eadaa93958220b7976389 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 27 Aug 2023 14:34:14 +0200 Subject: [PATCH] Remove unnecessary `mut` and document possible panic --- src/cache.rs | 2 +- src/telemetry.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cache.rs b/src/cache.rs index b8fc803..86458e2 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -74,7 +74,7 @@ impl<'a> CacheState<'a> { trace!("Calculating new cache"); match self { CacheState::Old { mut cache, .. } => { - if let Some(mut cache) = cache.entries.get_mut(branch) { + if let Some(cache) = cache.entries.get_mut(branch) { cache.head = head; cache.count += count; cache.commits += commits; diff --git a/src/telemetry.rs b/src/telemetry.rs index e19fd1a..9c4a851 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -15,6 +15,10 @@ pub fn get_subscriber(name: &str, env_filter: &str) -> impl Subscriber + Send + .with(formatting_layer) } +/// # Panics +/// +/// This panics if the `LogTracer` cannot be initialized or `subscriber` cannot be set as global +/// default. pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) { LogTracer::init().expect("Failed to set logger"); set_global_default(subscriber).expect("Failed to set tracing subscriber");