Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: simplify string formatting #1060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
style: simplify string formatting
  • Loading branch information
hamirmahal committed Aug 11, 2024
commit a4327a04b718e5b71f399a1cea456523fb1064d1
3 changes: 1 addition & 2 deletions crates/neon/src/types_impl/buffer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ where

if (len * elt_size) != size {
return cx.throw_range_error(format!(
"byte length of typed array should be a multiple of {}",
elt_size
"byte length of typed array should be a multiple of {elt_size}"
));
}

Expand Down
4 changes: 2 additions & 2 deletions crates/neon/src/types_impl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ pub(crate) fn convert_panics<T, F: UnwindSafe + FnOnce() -> NeonResult<T>>(
Ok(result) => result,
Err(panic) => {
let msg = if let Some(string) = panic.downcast_ref::<String>() {
format!("internal error in Neon module: {}", string)
format!("internal error in Neon module: {string}")
} else if let Some(str) = panic.downcast_ref::<&str>() {
format!("internal error in Neon module: {}", str)
format!("internal error in Neon module: {str}")
} else {
"internal error in Neon module".to_string()
};
Expand Down
2 changes: 1 addition & 1 deletion crates/neon/src/types_impl/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> Utf8<'a> {
pub fn into_small_unwrap(self) -> SmallUtf8<'a> {
let size = self.size();
self.into_small().unwrap_or_else(|| {
panic!("{} >= i32::MAX", size);
panic!("{size} >= i32::MAX");
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/napi/src/js/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn throw_error(mut cx: FunctionContext) -> JsResult<JsUndefined> {
pub fn downcast_error(mut cx: FunctionContext) -> JsResult<JsString> {
let s = cx.string("hi");
if let Err(e) = s.downcast::<JsNumber, _>(&mut cx) {
Ok(cx.string(format!("{}", e)))
Ok(cx.string(format!("{e}")))
} else {
panic!()
}
Expand Down
2 changes: 1 addition & 1 deletion test/napi/src/js/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn channel_join(mut cx: FunctionContext) -> JsResult<JsUndefined> {
.unwrap();

// Process the message
let response = format!("Received: {}", message);
let response = format!("Received: {message}");

// Call back to JavaScript with the response
channel.send(move |mut cx| {
Expand Down