Skip to content

Commit 714fc8f

Browse files
committed
style: Inline fmt args
1 parent 205f1de commit 714fc8f

File tree

13 files changed

+24
-29
lines changed

13 files changed

+24
-29
lines changed

crates/config/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl fmt::Display for Config {
114114
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
115115
let mut converted = serde_yaml::to_string(self).map_err(|_| fmt::Error)?;
116116
converted.drain(..4);
117-
write!(f, "{}", converted)
117+
write!(f, "{converted}")
118118
}
119119
}
120120

crates/config/src/document.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ mod test {
187187
fn split_document_no_new_line_after_front_matter() {
188188
let input = "invalid_front_matter---\nbody";
189189
let (cobalt_model, content) = split_document(input);
190-
println!("{:?}", cobalt_model);
190+
println!("{cobalt_model:?}");
191191
assert!(cobalt_model.is_none());
192192
assert_eq!(content, input);
193193
}
@@ -196,7 +196,7 @@ mod test {
196196
fn split_document_multiline_body() {
197197
let input = "---\ncobalt_model\n---\nfirst\nsecond";
198198
let (cobalt_model, content) = split_document(input);
199-
println!("{:?}", cobalt_model);
199+
println!("{cobalt_model:?}");
200200
assert_eq!(cobalt_model.unwrap(), "cobalt_model\n");
201201
assert_eq!(content, "first\nsecond");
202202
}

crates/config/src/frontmatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl fmt::Display for Frontmatter {
145145
if converted.is_empty() {
146146
Ok(())
147147
} else {
148-
write!(f, "{}", converted)
148+
write!(f, "{converted}")
149149
}
150150
}
151151
}

crates/config/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ mod test_rel_path {
324324
#[test]
325325
fn test_try_from_abspath_fails() {
326326
let case = RelPath::try_from("/foo/bar");
327-
println!("{:?}", case);
327+
println!("{case:?}");
328328
assert!(case.is_err());
329329
}
330330
}

crates/engarde/src/raw.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ impl Raw {
2727
pub fn format(&self, code: &str, lang: Option<&str>, _theme: Option<&str>) -> String {
2828
let code = html_escape(code);
2929
if let Some(ref lang) = lang {
30-
format!(
31-
"<pre><code class=\"language-{}\">{}</code></pre>\n",
32-
lang, code
33-
)
30+
format!("<pre><code class=\"language-{lang}\">{code}</code></pre>\n")
3431
} else {
35-
format!("<pre><code>{}</code></pre>\n", code)
32+
format!("<pre><code>{code}</code></pre>\n")
3633
}
3734
}
3835
}

crates/file-serve/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl ServerBuilder {
7070

7171
Server {
7272
source,
73-
addr: format!("{}:{}", hostname, port),
73+
addr: format!("{hostname}:{port}"),
7474
server: RwLock::new(None),
7575
}
7676
}
@@ -198,7 +198,7 @@ fn static_file_handler(dest: &std::path::Path, req: tiny_http::Request) -> Resul
198198
let file = std::fs::File::open(&serve_path).map_err(Error::new)?;
199199
let mut response = tiny_http::Response::from_file(file);
200200
if let Some(mime) = mime_guess::MimeGuess::from_path(&serve_path).first_raw() {
201-
let content_type = format!("Content-Type:{}", mime);
201+
let content_type = format!("Content-Type:{mime}");
202202
let content_type =
203203
tiny_http::Header::from_str(&content_type).expect("formatted correctly");
204204
response.add_header(content_type);

crates/file-serve/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fn main() {
22
let path = match std::env::current_dir() {
33
Ok(path) => path,
44
Err(err) => {
5-
eprintln!("Cannot serve CWD: {}", err);
5+
eprintln!("Cannot serve CWD: {err}");
66
std::process::exit(1);
77
}
88
};

src/bin/cobalt/debug.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ impl DebugCommands {
4242
Self::Config { config } => {
4343
let config = config.load_config()?;
4444
let config = cobalt::cobalt_model::Config::from_config(config)?;
45-
println!("{}", config);
45+
println!("{config}");
4646
}
4747
Self::Highlight(HighlightCommands::Themes { config }) => {
4848
let config = config.load_config()?;
4949
let config = cobalt::cobalt_model::Config::from_config(config)?;
5050
for name in config.syntax.themes() {
51-
println!("{}", name);
51+
println!("{name}");
5252
}
5353
}
5454
Self::Highlight(HighlightCommands::Syntaxes { config }) => {
5555
let config = config.load_config()?;
5656
let config = cobalt::cobalt_model::Config::from_config(config)?;
5757
for name in config.syntax.syntaxes() {
58-
println!("{}", name);
58+
println!("{name}");
5959
}
6060
}
6161
Self::Files { collection, config } => {

src/bin/cobalt/new.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub(crate) fn create_new_document(
243243
(parent_dir, filename, ext)
244244
};
245245

246-
let interim_path = parent_dir.join(format!("NON_EXISTENT.{}", extension));
246+
let interim_path = parent_dir.join(format!("NON_EXISTENT.{extension}"));
247247
let interim_path = cobalt_core::SourcePath::from_root(&config.source, &interim_path)
248248
.ok_or_else(|| {
249249
anyhow::format_err!(
@@ -271,7 +271,7 @@ pub(crate) fn create_new_document(
271271

272272
let source_path = config
273273
.source
274-
.join(format!("_defaults/{}.{}", collection_slug, extension));
274+
.join(format!("_defaults/{collection_slug}.{extension}"));
275275
let source = if source_path.is_file() {
276276
cobalt_model::files::read_file(&source_path)
277277
.with_context(|| anyhow::format_err!("Failed to read default: {:?}", source_path))?

src/bin/cobalt/serve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn serve(server: &file_serve::Server) -> Result<()> {
9797
fn open_browser(url: String) -> Result<()> {
9898
match open::that(url) {
9999
Ok(()) => info!("Please check your browser!"),
100-
Err(why) => eprintln!("Failure to execute command: {}", why),
100+
Err(why) => eprintln!("Failure to execute command: {why}"),
101101
}
102102
Ok(())
103103
}

src/cobalt_model/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ impl Config {
8080
ignore.push(format!("/{}", rel_dest.to_owned()).into());
8181
}
8282
}
83-
ignore.push(format!("/{}", includes_dir).into());
84-
ignore.push(format!("/{}", layouts_dir).into());
83+
ignore.push(format!("/{includes_dir}").into());
84+
ignore.push(format!("/{layouts_dir}").into());
8585
ignore.push("/_defaults".into());
8686
ignore.push(format!("/{}", assets.sass.import_dir).into());
8787
assert_eq!(pages.dir, "");
8888
assert_eq!(pages.drafts_dir, None);
8989
ignore.push(format!("!/{}", posts.dir).into());
9090
if let Some(dir) = posts.drafts_dir.as_deref() {
91-
ignore.push(format!("!/{}", dir).into());
91+
ignore.push(format!("!/{dir}").into());
9292
}
9393
ignore.extend(custom_ignore);
9494

@@ -151,7 +151,7 @@ impl fmt::Display for Config {
151151
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152152
let mut converted = serde_yaml::to_string(self).map_err(|_| fmt::Error)?;
153153
converted.drain(..4);
154-
write!(f, "{}", converted)
154+
write!(f, "{converted}")
155155
}
156156
}
157157

src/cobalt_model/frontmatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl fmt::Display for Frontmatter {
110110
if converted.is_empty() {
111111
Ok(())
112112
} else {
113-
write!(f, "{}", converted)
113+
write!(f, "{converted}")
114114
}
115115
}
116116
}

src/syntax_highlight.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ mod test_syntsx {
241241
.unwrap();
242242
let template = parser
243243
.parse(&format!(
244-
"{{% highlight rust %}}{}{{% endhighlight %}}",
245-
CODE_BLOCK
244+
"{{% highlight rust %}}{CODE_BLOCK}{{% endhighlight %}}"
246245
))
247246
.unwrap();
248247
let output = template.render(&liquid::Object::new());
@@ -264,9 +263,8 @@ mod test_syntsx {
264263
fn markdown_renders_rust() {
265264
let html = format!(
266265
"```rust
267-
{}
268-
```",
269-
CODE_BLOCK
266+
{CODE_BLOCK}
267+
```"
270268
);
271269

272270
let mut buf = String::new();

0 commit comments

Comments
 (0)