Skip to content

Commit 2683366

Browse files
committed
clippy
1 parent b143c39 commit 2683366

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

benches/rotation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ impl Stats {
141141
let mut anomalies = vec![];
142142
let thresh = self.mean_nanos + ((self.stddev_nanos * 50.0).round() as u128);
143143
for dur in measurements {
144-
if dur.as_nanos() as u128 > thresh {
145-
anomalies.push(dur.clone());
144+
if dur.as_nanos() > thresh {
145+
anomalies.push(*dur);
146146
}
147147
}
148148
anomalies

src/append/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ mod test {
327327
.unwrap();
328328

329329
// Only MAX_REPLACEMENTS should be replaced, the rest should remain as $TIME{...}
330-
let mut expected_path = format!("foo/bar/logs/log");
330+
let mut expected_path = "foo/bar/logs/log".to_string();
331331
for i in 0..10 {
332332
if i < MAX_REPLACEMENTS {
333333
expected_path.push_str(&format!("-{}", current_time));

src/append/rolling_file/policy/compound/roll/fixed_window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ mod test {
471471
wait_for_roller(&roller);
472472
assert!(!file.exists());
473473
contents.clear();
474-
File::open(dir.path().join(&format!("{}.{}", fname, base + 1)))
474+
File::open(dir.path().join(format!("{}.{}", fname, base + 1)))
475475
.unwrap()
476476
.read_to_end(&mut contents)
477477
.unwrap();

src/append/rolling_file/policy/compound/trigger/time.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ mod test {
444444
#[test]
445445
#[cfg(feature = "yaml_format")]
446446
fn test_serde() {
447-
let test_error = vec![
447+
let test_error = [
448448
"abc", // // str none none
449449
"", // none
450450
"5 das", // bad unit
@@ -453,7 +453,7 @@ mod test {
453453
];
454454

455455
for interval in test_error.iter() {
456-
let error = ::serde_yaml::from_str::<TimeTriggerInterval>(&interval);
456+
let error = ::serde_yaml::from_str::<TimeTriggerInterval>(interval);
457457
assert!(error.is_err());
458458
}
459459

@@ -483,7 +483,7 @@ mod test {
483483
("1 years", TimeTriggerInterval::Year(1)),
484484
];
485485
for (interval, expected) in test_ok.iter() {
486-
let interval = format!("{}", interval);
486+
let interval = interval.to_string();
487487
let interval = ::serde_yaml::from_str::<TimeTriggerInterval>(&interval).unwrap();
488488
assert_eq!(interval, *expected);
489489
}

src/encode/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub trait Write: io::Write {
147147
}
148148
}
149149

150-
impl<'a, W: Write + ?Sized> Write for &'a mut W {
150+
impl<W: Write + ?Sized> Write for &mut W {
151151
fn set_style(&mut self, style: &Style) -> io::Result<()> {
152152
<W as Write>::set_style(*self, style)
153153
}

src/encode/pattern/mod.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,50 @@
4141
//! a formatter does not accept any argument.
4242
//!
4343
//! * `d`, `date` - The current time. By default, the ISO 8601 format is used.
44-
//! A custom format may be provided in the syntax accepted by `chrono`.
45-
//! The timezone defaults to local, but can be specified explicitly by
46-
//! passing a second argument of `utc` for UTC or `local` for local time.
47-
//! * `{d}` - `2016-03-20T14:22:20.644420340-08:00`
48-
//! * `{d(%Y-%m-%d %H:%M:%S)}` - `2016-03-20 14:22:20`
49-
//! * `{d(%Y-%m-%d %H:%M:%S %Z)(utc)}` - `2016-03-20 22:22:20 UTC`
44+
//! A custom format may be provided in the syntax accepted by `chrono`.
45+
//! The timezone defaults to local, but can be specified explicitly by
46+
//! passing a second argument of `utc` for UTC or `local` for local time.
47+
//! * `{d}` - `2016-03-20T14:22:20.644420340-08:00`
48+
//! * `{d(%Y-%m-%d %H:%M:%S)}` - `2016-03-20 14:22:20`
49+
//! * `{d(%Y-%m-%d %H:%M:%S %Z)(utc)}` - `2016-03-20 22:22:20 UTC`
5050
//! * `f`, `file` - The source file that the log message came from, or `???` if
51-
//! not provided.
51+
//! not provided.
5252
//! * `h`, `highlight` - Styles its argument according to the log level. The
53-
//! style is intense red for errors, red for warnings, blue for info, and
54-
//! the default style for all other levels.
55-
//! * `{h(the level is {l})}` -
56-
//! <code style="color: red; font-weight: bold">the level is ERROR</code>
53+
//! style is intense red for errors, red for warnings, blue for info, and
54+
//! the default style for all other levels.
55+
//! * `{h(the level is {l})}` -
56+
//! <code style="color: red; font-weight: bold">the level is ERROR</code>
5757
//! * `D`, `debug` - Outputs its arguments ONLY in debug build.
5858
//! * `R`, `release` - Outputs its arguments ONLY in release build.
5959
//! * `l`, `level` - The log level.
6060
//! * `L`, `line` - The line that the log message came from, or `???` if not
61-
//! provided.
61+
//! provided.
6262
//! * `m`, `message` - The log message.
6363
//! * `M`, `module` - The module that the log message came from, or `???` if not
64-
//! provided.
64+
//! provided.
6565
//! * `P`, `pid` - The current process id.
6666
//! * `i`, `tid` - The current system-wide unique thread ID.
6767
//! * `n` - A platform-specific newline.
6868
//! * `t`, `target` - The target of the log message.
6969
//! * `T`, `thread` - The name of the current thread.
7070
//! * `I`, `thread_id` - The pthread ID of the current thread.
7171
//! * `X`, `mdc` - A value from the [MDC][MDC]. The first argument specifies
72-
//! the key, and the second argument specifies the default value if the
73-
//! key is not present in the MDC. The second argument is optional, and
74-
//! defaults to the empty string.
72+
//! the key, and the second argument specifies the default value if the
73+
//! key is not present in the MDC. The second argument is optional, and
74+
//! defaults to the empty string.
7575
//! * `{X(user_id)}` - `123e4567-e89b-12d3-a456-426655440000`
7676
//! * `{X(nonexistent_key)(no mapping)}` - `no mapping`
7777
//! * `K`, `key_value` - A value from a [log::kv][log_kv] structured logging
78-
//! record attributes. The first argument specifies the key, and the second
79-
//! argument specifies the default value if the key is not present in the
80-
//! log record's attributes. The second argument is optional, and defaults
81-
//! to the empty string. This formatter requires the `log_kv` feature to be
82-
//! enabled.
83-
//! * `{K(user_id)}` - `123e4567-e89b-12d3-a456-426655440000`
84-
//! * `{K(nonexistent_key)(no mapping)}` - `no mapping`
78+
//! record attributes. The first argument specifies the key, and the second
79+
//! argument specifies the default value if the key is not present in the
80+
//! log record's attributes. The second argument is optional, and defaults
81+
//! to the empty string. This formatter requires the `log_kv` feature to be
82+
//! enabled.
83+
//! * `{K(user_id)}` - `123e4567-e89b-12d3-a456-426655440000`
84+
//! * `{K(nonexistent_key)(no mapping)}` - `no mapping`
8585
//! * An "unnamed" formatter simply formats its argument, applying the format
86-
//! specification.
87-
//! * `{({l} {m})}` - `INFO hello`
86+
//! specification.
87+
//! * `{({l} {m})}` - `INFO hello`
8888
//!
8989
//! # Format Specification
9090
//!
@@ -101,7 +101,7 @@
101101
//!
102102
//! * `<` - Left align by appending the fill character to the formatter output
103103
//! * `>` - Right align by prepending the fill character to the formatter
104-
//! output.
104+
//! output.
105105
//!
106106
//! ## Width
107107
//!
@@ -183,7 +183,7 @@ enum Chunk {
183183
}
184184

185185
impl Chunk {
186-
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_> ) -> io::Result<()> {
186+
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_>) -> io::Result<()> {
187187
match *self {
188188
Chunk::Text(ref s) => w.write_all(s.as_bytes()),
189189
Chunk::Formatted {
@@ -546,7 +546,7 @@ fn no_args(arg: &[Vec<Piece<'_>>], params: Parameters, chunk: FormattedChunk) ->
546546
}
547547
}
548548

549-
fn kv_parsing<'a>(formatter: &'a Formatter<'_> ) -> Result<(String, String), &'a str> {
549+
fn kv_parsing<'a>(formatter: &'a Formatter<'_>) -> Result<(String, String), &'a str> {
550550
if formatter.args.len() > 2 {
551551
return Err("expected at most two arguments");
552552
}
@@ -613,7 +613,7 @@ enum FormattedChunk {
613613
}
614614

615615
impl FormattedChunk {
616-
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_> ) -> io::Result<()> {
616+
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_>) -> io::Result<()> {
617617
match *self {
618618
FormattedChunk::Time(ref fmt, Timezone::Utc) => write!(w, "{}", Utc::now().format(fmt)),
619619
FormattedChunk::Time(ref fmt, Timezone::Local) => {
@@ -718,7 +718,7 @@ impl Default for PatternEncoder {
718718
}
719719

720720
impl Encode for PatternEncoder {
721-
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_> ) -> anyhow::Result<()> {
721+
fn encode(&self, w: &mut dyn encode::Write, record: &Record<'_>) -> anyhow::Result<()> {
722722
for chunk in &self.chunks {
723723
chunk.encode(w, record)?;
724724
}
@@ -790,10 +790,10 @@ mod tests {
790790
use crate::encode::Encode;
791791

792792
fn error_free(encoder: &PatternEncoder) -> bool {
793-
encoder.chunks.iter().all(|c| match *c {
794-
Chunk::Error(_) => false,
795-
_ => true,
796-
})
793+
encoder
794+
.chunks
795+
.iter()
796+
.all(|c| !matches!(*c, Chunk::Error(_)))
797797
}
798798

799799
#[test]

tests/color_control.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::process::Command;
22

33
fn execute_test(env_key: &str, env_val: &str) {
44
let mut child_proc = Command::new("cargo")
5-
.args(&["run", "--example", "compile_time_config"])
5+
.args(["run", "--example", "compile_time_config"])
66
.env(env_key, env_val)
77
.spawn()
88
.expect("Cargo command failed to start");

0 commit comments

Comments
 (0)