Skip to content

Commit a3ae073

Browse files
clippy
1 parent 5520041 commit a3ae073

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

crates/ruff_linter/src/rules/pylint/rules/unspecified_encoding.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use std::fmt::{Display, Formatter};
23

34
use ast::StringLiteralFlags;
45
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Fix};
@@ -121,17 +122,19 @@ impl<'a> Segments<'a> {
121122
}
122123
None
123124
}
125+
}
124126

125-
fn to_string(&self) -> String {
127+
impl Display for Segments<'_> {
128+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
126129
match self {
127130
Segments::Regular(segments) => {
128-
if segments[0] == "" {
129-
segments[1..].join(".")
131+
if segments[0].is_empty() {
132+
f.write_str(&segments[1..].join("."))
130133
} else {
131-
segments.join(".")
134+
f.write_str(&segments.join("."))
132135
}
133136
}
134-
Segments::Pathlib(attr) => format!("pathlib.Path.{attr}"),
137+
Segments::Pathlib(attr) => f.write_str(&format!("pathlib.Path.{attr}")),
135138
}
136139
}
137140
}

0 commit comments

Comments
 (0)