RS.CLIPPY.USELESS_FORMAT
Useless use of `format!`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: useless_format. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for the use of format!("string literal with no argument") and format!("{}", foo) where foo is a string.
Why is this bad?
There is no point of doing that. format!("foo") can
be replaced by "foo".to_owned() if you really need a String. The even
worse &format!("foo") is often encountered in the wild. format!("{}", foo) can be replaced by foo.clone() if foo: String or foo.to_owned()
if foo: &str.
Examples
let foo = "foo";
format!("{}", foo);
Use instead:
let foo = "foo";
foo.to_owned();