Skip to content

Commit

Permalink
clippy clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano committed Dec 31, 2023
1 parent b6bb928 commit 7192051
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
3 changes: 1 addition & 2 deletions rust-script/src/runtime/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use crate::{
apply::Apply,
script_registry::{
CreateScriptInstanceData_TO, RemoteGodotScript_TO, RemoteScriptMetaData,
RemoteScriptPropertyInfo,
RemoteScriptMethodInfo, RemoteScriptPropertyInfo,
},
RemoteScriptMethodInfo,
};

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion rust-script/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro_rules! deinit {
}

static SCRIPT_REGISTRY: Lazy<RwLock<HashMap<String, ScriptMetaData>>> =
Lazy::new(|| RwLock::default());
Lazy::new(RwLock::default);

#[derive(GodotClass)]
#[class(base = Object, init)]
Expand Down
25 changes: 11 additions & 14 deletions rust-script/src/runtime/rust_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl RustScript {

*self.owners.borrow_mut() = ids
.iter_shared()
.map(|raw_id| InstanceId::from_i64(raw_id))
.map(InstanceId::from_i64)
.filter_map(|id| {
godot_print!(
"reloading script instance of {}, {}",
Expand Down Expand Up @@ -193,7 +193,7 @@ impl IScriptExtension for RustScript {
let data = self.create_remote_instance(for_object.clone());
let instance = RustScriptInstance::new(data, for_object, self.base.deref().clone().cast());

create_script_instance(instance) as *mut c_void
create_script_instance(instance)
}

unsafe fn placeholder_instance_create(&self, for_object: Gd<Object>) -> *mut c_void {
Expand All @@ -208,7 +208,7 @@ impl IScriptExtension for RustScript {

let placeholder = RustScriptPlaceholder::new(self.base.deref().clone().cast());

create_script_instance(placeholder) as *mut c_void
create_script_instance(placeholder)
}

fn is_valid(&self) -> bool {
Expand Down Expand Up @@ -260,7 +260,7 @@ impl IScriptExtension for RustScript {
class
.methods()
.iter()
.any(|method| method.method_name.to_string() == method_name.to_string())
.any(|method| method.method_name == method_name.to_string())
})
}

Expand All @@ -276,7 +276,7 @@ impl IScriptExtension for RustScript {
class
.methods()
.iter()
.find(|method| method.method_name.to_string() == method_name.to_string())
.find(|method| method.method_name == method_name.to_string())
.map(|method| MethodInfo::from(method.to_owned()).to_dict())
})
.unwrap_or_default()
Expand Down Expand Up @@ -369,16 +369,13 @@ impl IScriptExtension for RustScript {
}

fn on_notification(&mut self, what: ObjectNotification) {
match what {
ObjectNotification::Unknown(NOTIFICATION_EXTENSION_RELOADED) => {
godot_print!(
"RustScript({}): received extension reloaded notification!",
self.str_class_name()
);
if let ObjectNotification::Unknown(NOTIFICATION_EXTENSION_RELOADED) = what {
godot_print!(
"RustScript({}): received extension reloaded notification!",
self.str_class_name()
);

self.reload(false);
}
_ => (),
self.reload(false);
}
}
}
7 changes: 3 additions & 4 deletions rust-script/src/runtime/rust_script_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn script_method_list(script: &Gd<RustScript>) -> Rc<Vec<MethodInfo>> {
.map(|meta| {
Rc::new(
meta.methods()
.into_iter()
.iter()
.map(|method| MethodInfo::from(method.to_owned()))
.collect(),
)
Expand All @@ -56,7 +56,7 @@ fn script_property_list(script: &Gd<RustScript>) -> Rc<Vec<PropertyInfo>> {
.map(|meta| {
Rc::new(
meta.properties()
.into_iter()
.iter()
.map(|prop| PropertyInfo::from(prop.to_owned()))
.collect(),
)
Expand Down Expand Up @@ -161,8 +161,7 @@ impl ScriptInstance for RustScriptInstance {
fn has_method(&self, method_name: StringName) -> bool {
self.method_list
.iter()
.find(|method| method.method_name == method_name)
.is_some()
.any(|method| method.method_name == method_name)
}

fn get_property_type(&self, name: StringName) -> godot::sys::VariantType {
Expand Down
2 changes: 1 addition & 1 deletion rust-script/tests/macro_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ godot_rust_script::setup!(tests_scripts_lib);

#[test]
fn verify_macros() {
let _ = godot_rust_script::init!();
godot_rust_script::init!();
}

0 comments on commit 7192051

Please sign in to comment.