Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrieshiemstra committed Jan 3, 2024
1 parent 4f7d224 commit 93a0082
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/features/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ unsafe fn parse_field_value(
}

if field.ends_with('d') || field.ends_with('i') {
let mut i_val: String = call_to_string(ctx, value).unwrap_or(String::new());
let mut i_val: String = call_to_string(ctx, value).unwrap_or_default();

// remove chars behind .
if let Some(i) = i_val.find('.') {
Expand Down Expand Up @@ -117,7 +117,7 @@ unsafe fn parse_field_value(

return i_val;
} else if field.ends_with('f') {
let mut f_val: String = call_to_string(ctx, value).unwrap_or(String::new());
let mut f_val: String = call_to_string(ctx, value).unwrap_or_default();

if let Some(dot_in_field_idx) = field.find('.') {
let mut m_field = field.to_string();
Expand Down Expand Up @@ -152,12 +152,12 @@ unsafe fn parse_field_value(
} else if field.ends_with('o') || field.ends_with('O') {
let json_str_res = json::stringify(ctx, value, None);
let json = match json_str_res {
Ok(json_str) => primitives::to_string(ctx, &json_str).unwrap_or(String::new()),
Ok(json_str) => primitives::to_string(ctx, &json_str).unwrap_or_default(),
Err(_e) => "".to_string(),
};
return json;
}
call_to_string(ctx, value).unwrap_or(String::new())
call_to_string(ctx, value).unwrap_or_default()
}

unsafe fn stringify_log_obj(ctx: *mut q::JSContext, arg: &QuickJsValueAdapter) -> String {
Expand Down Expand Up @@ -193,7 +193,7 @@ unsafe fn parse_line(ctx: *mut q::JSContext, args: Vec<QuickJsValueAdapter>) ->
JsValueType::Object => stringify_log_obj(ctx, &args[0]),
JsValueType::Function => stringify_log_obj(ctx, &args[0]),
JsValueType::Array => stringify_log_obj(ctx, &args[0]),
_ => functions::call_to_string(ctx, &args[0]).unwrap_or(String::new()),
_ => functions::call_to_string(ctx, &args[0]).unwrap_or_default(),
};

let mut field_code = String::new();
Expand Down Expand Up @@ -238,7 +238,7 @@ unsafe fn parse_line(ctx: *mut q::JSContext, args: Vec<QuickJsValueAdapter>) ->
JsValueType::Object => stringify_log_obj(ctx, arg),
JsValueType::Function => stringify_log_obj(ctx, arg),
JsValueType::Array => stringify_log_obj(ctx, arg),
_ => call_to_string(ctx, arg).unwrap_or(String::new()),
_ => call_to_string(ctx, arg).unwrap_or_default(),
};
output.push_str(tail_arg.as_str());
}
Expand Down
1 change: 0 additions & 1 deletion src/quickjs_utils/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ pub unsafe fn set_element(
index: u32,
entry_value_ref: &QuickJsValueAdapter,
) -> Result<(), JsError> {
let entry_value_ref = entry_value_ref;

let ret = q::JS_DefinePropertyValueUint32(
context,
Expand Down
2 changes: 1 addition & 1 deletion src/quickjs_utils/promises.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub unsafe fn new_promise(context: *mut q::JSContext) -> Result<QuickJsPromiseAd

let prom_val = q::JS_NewPromiseCapability(context, promise_resolution_functions.as_mut_ptr());

let resolve_func_val = *promise_resolution_functions.get(0).unwrap();
let resolve_func_val = *promise_resolution_functions.first().unwrap();
let reject_func_val = *promise_resolution_functions.get(1).unwrap();

let resolve_function_obj_ref = QuickJsValueAdapter::new(
Expand Down
3 changes: 2 additions & 1 deletion src/reflection/eventtarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
with_proxy_instances_map_mut(q_ctx, proxy_class_name, |proxy_instance_map| {
let event_id_map = proxy_instance_map
.entry(instance_id)
.or_insert_with(HashMap::new);
.or_default();

if !event_id_map.contains_key(event_id) {
event_id_map.insert(event_id.to_string(), HashMap::new());
Expand Down Expand Up @@ -552,6 +552,7 @@ unsafe extern "C" fn ext_dispatch_static_event(
let res =
dispatch_static_event(q_ctx, proxy_name.as_str(), event_id.as_str(), evt_obj)?;


Ok(res)
}
});
Expand Down

0 comments on commit 93a0082

Please sign in to comment.