From e6c9cfb0c13ee122b51fe0edc5a8e9e25a7ddecf Mon Sep 17 00:00:00 2001 From: Akulij Date: Sat, 7 Jun 2025 02:27:05 +0500 Subject: [PATCH] fix warnings in botscript.rs --- src/botscript.rs | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/botscript.rs b/src/botscript.rs index 999fb41..f567079 100644 --- a/src/botscript.rs +++ b/src/botscript.rs @@ -760,7 +760,11 @@ impl NotificationFilter { NotificationFilter::Random { random } => Ok(db.get_random_users(*random).await?), NotificationFilter::BotFunction(f) => { let users = f.call()?; - let users = from_js(f.context().unwrap(), &users)?; + // we just called function, so context is definetly valid + let users = from_js( + f.context().expect("Context invalid after function call"), + &users, + )?; Ok(users) } } @@ -768,7 +772,7 @@ impl NotificationFilter { } impl Parcelable for NotificationFilter { - fn get_field(&mut self, name: &str) -> ParcelableResult> { + fn get_field(&mut self, _name: &str) -> ParcelableResult> { todo!() } @@ -798,7 +802,7 @@ pub enum NotificationMessage { } impl Parcelable for NotificationMessage { - fn get_field(&mut self, name: &str) -> ParcelableResult> { + fn get_field(&mut self, _name: &str) -> ParcelableResult> { todo!() } @@ -1060,7 +1064,6 @@ impl Runner { #[allow(clippy::unwrap_used)] #[allow(clippy::print_stdout)] mod tests { - use quickjs_rusty::OwnedJsObject; use serde_json::json; use super::*; @@ -1106,22 +1109,6 @@ mod tests { assert_eq!(sres, "cancelation"); } - fn recursive_format(o: OwnedJsObject) -> String { - let props: Vec<_> = o.properties_iter().unwrap().map(|x| x.unwrap()).collect(); - let sp: Vec = props - .into_iter() - .map(|v| { - if v.is_object() { - recursive_format(v.try_into_object().unwrap()) - } else { - format!("{:?}", v) - } - }) - .collect(); - - format!("{:?}", sp) - } - #[test] fn test_run_script_invalid() { let runner = Runner::init().unwrap();