chore: simplify string interpolation (#2626)

This commit is contained in:
Hamir Mahal 2024-06-21 04:51:38 -07:00 committed by GitHub
parent 80bbb20089
commit c9d0ef5033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 23 deletions

View File

@ -228,7 +228,7 @@ impl ToTokens for Model {
let component_id = name.to_string();
let hydrate_fn_name =
Ident::new(&format!("_island_{}", component_id), name.span());
Ident::new(&format!("_island_{component_id}"), name.span());
let island_serialize_props = if is_island_with_other_props {
quote! {
@ -1235,7 +1235,7 @@ pub fn unmodified_fn_name_from_fn_name(ident: &Ident) -> Ident {
/// Converts all `impl Trait`s in a function signature to use generic params instead.
fn convert_impl_trait_to_generic(sig: &mut Signature) {
fn new_generic_ident(i: usize, span: Span) -> Ident {
Ident::new(&format!("__ImplTrait{}", i), span)
Ident::new(&format!("__ImplTrait{i}"), span)
}
// First: visit all `impl Trait`s and replace them with new generic params.

View File

@ -19,8 +19,8 @@ fn watch_runs() {
move |a, prev_a, prev_ret| {
let formatted = format!(
"Value is {}; Prev is {:?}; Prev return is {:?}",
a, prev_a, prev_ret
"Value is {a}; Prev is {prev_a:?}; Prev return is \
{prev_ret:?}"
);
*b.borrow_mut() = formatted;
@ -72,8 +72,8 @@ fn watch_runs_immediately() {
move |a, prev_a, prev_ret| {
let formatted = format!(
"Value is {}; Prev is {:?}; Prev return is {:?}",
a, prev_a, prev_ret
"Value is {a}; Prev is {prev_a:?}; Prev return is \
{prev_ret:?}"
);
*b.borrow_mut() = formatted;

View File

@ -601,9 +601,9 @@ mod tests {
#[test]
fn debug_fmt_should_display_quotes_for_strings() {
let s: Oco<str> = Oco::Borrowed("hello");
assert_eq!(format!("{:?}", s), "\"hello\"");
assert_eq!(format!("{s:?}"), "\"hello\"");
let s: Oco<str> = Oco::Counted(Rc::from("hello"));
assert_eq!(format!("{:?}", s), "\"hello\"");
assert_eq!(format!("{s:?}"), "\"hello\"");
}
#[test]

View File

@ -98,7 +98,7 @@ impl<'b, 'a: 'b> StaticPath<'b, 'a> {
Static(s) => {
paths = paths
.into_iter()
.map(|p| ResolvedStaticPath(format!("{}/{}", p, s)))
.map(|p| ResolvedStaticPath(format!("{p}/{s}")))
.collect::<Vec<_>>();
}
Param(name) | Wildcard(name) => {
@ -112,8 +112,7 @@ impl<'b, 'a: 'b> StaticPath<'b, 'a> {
};
for val in params.iter() {
new_paths.push(ResolvedStaticPath(format!(
"{}/{}",
path, val
"{path}/{val}"
)));
}
}
@ -177,7 +176,7 @@ impl ResolvedStaticPath {
where
IV: IntoView + 'static,
{
let url = format!("http://leptos{}", self);
let url = format!("http://leptos{self}");
let app = {
let app_fn = app_fn.clone();
move || {
@ -272,7 +271,7 @@ where
}
#[allow(clippy::print_stdout)]
for path in path.into_paths() {
println!("building static route: {}", path);
println!("building static route: {path}");
path.write(options, app_fn.clone(), additional_context.clone())
.await?;
}

View File

@ -250,7 +250,7 @@ where
ServerFnError::MissingArg(s) => format!("missing argument {s}"),
ServerFnError::Response(s) =>
format!("error generating HTTP response: {s}"),
ServerFnError::WrappedServerError(e) => format!("{}", e),
ServerFnError::WrappedServerError(e) => format!("{e}"),
}
)
}
@ -281,25 +281,25 @@ where
let mut buf = String::new();
match self {
ServerFnError::WrappedServerError(e) => {
write!(&mut buf, "WrappedServerFn|{}", e)
write!(&mut buf, "WrappedServerFn|{e}")
}
ServerFnError::Registration(e) => {
write!(&mut buf, "Registration|{}", e)
write!(&mut buf, "Registration|{e}")
}
ServerFnError::Request(e) => write!(&mut buf, "Request|{}", e),
ServerFnError::Response(e) => write!(&mut buf, "Response|{}", e),
ServerFnError::Request(e) => write!(&mut buf, "Request|{e}"),
ServerFnError::Response(e) => write!(&mut buf, "Response|{e}"),
ServerFnError::ServerError(e) => {
write!(&mut buf, "ServerError|{}", e)
write!(&mut buf, "ServerError|{e}")
}
ServerFnError::Deserialization(e) => {
write!(&mut buf, "Deserialization|{}", e)
write!(&mut buf, "Deserialization|{e}")
}
ServerFnError::Serialization(e) => {
write!(&mut buf, "Serialization|{}", e)
write!(&mut buf, "Serialization|{e}")
}
ServerFnError::Args(e) => write!(&mut buf, "Args|{}", e),
ServerFnError::Args(e) => write!(&mut buf, "Args|{e}"),
ServerFnError::MissingArg(e) => {
write!(&mut buf, "MissingArg|{}", e)
write!(&mut buf, "MissingArg|{e}")
}
}?;
Ok(buf)