From b02417975ceba43cd832aba6bf0ed3fa4a06ef53 Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 21:30:05 +0900 Subject: [PATCH 1/6] allow `must_use_candidate` crate_wide --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 961ec85..addc062 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,6 +274,8 @@ //! assert!(counter.into_map() == expected); //! ``` + +#![allow(clippy::must_use_candidate)] mod impls; use num_traits::{One, Zero}; From d30b6baa2b0b2c295269f1bdb1dfc29f52f3e023 Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 21:30:52 +0900 Subject: [PATCH 2/6] fix `default_trait_access` --- src/impls/create.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/impls/create.rs b/src/impls/create.rs index 93d7a54..3f96b21 100644 --- a/src/impls/create.rs +++ b/src/impls/create.rs @@ -38,7 +38,7 @@ where { fn default() -> Self { Self { - map: Default::default(), + map: HashMap::default(), zero: Default::default(), } } From 354b5f96e50712e2e72de16c8056548eb8f8a5f1 Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 21:34:28 +0900 Subject: [PATCH 3/6] `missing_panics_docs` I'm not sure if this can actually panic? --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index addc062..ce50b35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,7 +274,6 @@ //! assert!(counter.into_map() == expected); //! ``` - #![allow(clippy::must_use_candidate)] mod impls; @@ -499,6 +498,9 @@ where /// be worth experimenting to see which of the two methods is faster. /// /// [`most_common_ordered`]: Counter::most_common_ordered + /// + /// # Panics + /// Panics if heap is empty pub fn k_most_common_ordered(&self, k: usize) -> Vec<(T, N)> { use std::cmp::Reverse; From 93f6fba6c7290b3c56fb270d00d8425cc33c3c04 Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 22:47:04 +0900 Subject: [PATCH 4/6] Update create.rs --- src/impls/create.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/impls/create.rs b/src/impls/create.rs index 3f96b21..4b8309c 100644 --- a/src/impls/create.rs +++ b/src/impls/create.rs @@ -39,7 +39,7 @@ where fn default() -> Self { Self { map: HashMap::default(), - zero: Default::default(), + zero: N::default(), } } } From 1ab1d58cd0dddae66f7828a4649581b3ea15a0ad Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 22:52:01 +0900 Subject: [PATCH 5/6] amend panic docs reflects the fact that, despite the use of expect, current code does not panic --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ce50b35..9dab607 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -498,9 +498,9 @@ where /// be worth experimenting to see which of the two methods is faster. /// /// [`most_common_ordered`]: Counter::most_common_ordered - /// + /// /// # Panics - /// Panics if heap is empty + /// Preconditions ensure that the current implementation does not panic. pub fn k_most_common_ordered(&self, k: usize) -> Vec<(T, N)> { use std::cmp::Reverse; From eca86c596d5e545aade05133c2d5aee3faacc97d Mon Sep 17 00:00:00 2001 From: chris-ha458 Date: Tue, 19 Sep 2023 23:02:38 +0900 Subject: [PATCH 6/6] remove pointless `# panics` section --- src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9dab607..312ebd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -498,9 +498,7 @@ where /// be worth experimenting to see which of the two methods is faster. /// /// [`most_common_ordered`]: Counter::most_common_ordered - /// - /// # Panics - /// Preconditions ensure that the current implementation does not panic. + #[allow(clippy::missing_panics_doc)] // current implementation does not panic pub fn k_most_common_ordered(&self, k: usize) -> Vec<(T, N)> { use std::cmp::Reverse;