Skip to content

Commit 59f958e

Browse files
committed
Enable clippy lint must_use_candidate as "warn"
1 parent f4a7cfb commit 59f958e

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ keywords = ["spdlog", "log", "logging"]
1515
categories = ["development-tools::debugging"]
1616

1717
[workspace.lints.clippy]
18+
must_use_candidate = "warn"
1819
unused_trait_names = "warn"

spdlog-internal/src/pattern_parser/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,17 @@ impl BuiltInFormatter {
104104
BuiltInFormatterInner::iter().map(BuiltInFormatter)
105105
}
106106

107+
#[must_use]
107108
pub fn struct_name(&self) -> &'static str {
108109
BuiltInFormatterInnerDiscriminants::from(self.0).into()
109110
}
110111

112+
#[must_use]
111113
pub fn placeholder(&self) -> &'static str {
112114
self.0.into()
113115
}
114116

117+
#[must_use]
115118
pub fn inner(&self) -> BuiltInFormatterInner {
116119
self.0
117120
}

spdlog-internal/src/pattern_parser/registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct PatternRegistry<F> {
1414
}
1515

1616
impl<F> PatternRegistry<F> {
17+
#[must_use]
1718
pub fn with_builtin() -> Self {
1819
let mut registry = Self {
1920
formatters: HashMap::new(),

spdlog/src/kv.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ pub struct Key<'a>(RefStr<'a>);
100100

101101
impl Key<'_> {
102102
/// Gets the key string.
103+
#[must_use]
103104
pub fn as_str(&self) -> &str {
104105
self.0.get()
105106
}
106107
}
107108

108109
impl<'a> Key<'a> {
109110
#[doc(hidden)]
111+
#[must_use]
110112
pub fn __from_static_str(key: &'static str) -> Self {
111113
Key(RefStr::new_static(key))
112114
}
@@ -187,6 +189,7 @@ pub struct KeyValues<'a>(KeyValuesInner<'a>);
187189

188190
impl<'a> KeyValues<'a> {
189191
/// Gets the number of key-value pairs.
192+
#[must_use]
190193
pub fn len(&self) -> usize {
191194
match self.0 {
192195
KeyValuesInner::Borrowed(p) => p.len(),
@@ -195,6 +198,7 @@ impl<'a> KeyValues<'a> {
195198
}
196199

197200
/// Checks if there are no key-value pairs.
201+
#[must_use]
198202
pub fn is_empty(&self) -> bool {
199203
match self.0 {
200204
KeyValuesInner::Borrowed(p) => p.is_empty(),
@@ -203,6 +207,7 @@ impl<'a> KeyValues<'a> {
203207
}
204208

205209
/// Gets the value of the specified key.
210+
#[must_use]
206211
pub fn get(&self, key: Key) -> Option<Value<'a>> {
207212
match self.0 {
208213
KeyValuesInner::Borrowed(p) => {
@@ -274,6 +279,7 @@ impl<'a> IntoIterator for KeyValues<'a> {
274279
}
275280

276281
/// Represents an iterator over key-value pairs.
282+
#[must_use]
277283
pub struct KeyValuesIter<'a>(KeyValuesIterInner<'a>);
278284

279285
impl<'a> Iterator for KeyValuesIter<'a> {

spdlog/src/level.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl AtomicLevelFilter {
379379
const ORDERING: Ordering = Ordering::Relaxed;
380380

381381
/// Creates a new `AtomicLevelFilter`.
382+
#[must_use]
382383
pub fn new(init: LevelFilter) -> Self {
383384
Self {
384385
inner: atomic::Atomic::new(init.into()),

0 commit comments

Comments
 (0)