diff --git a/crates/gosub_css3/src/node.rs b/crates/gosub_css3/src/node.rs index e4ed49227..f150a0455 100644 --- a/crates/gosub_css3/src/node.rs +++ b/crates/gosub_css3/src/node.rs @@ -1,7 +1,8 @@ -use crate::location::Location; use core::fmt::{Display, Formatter}; use std::ops::Deref; +use crate::location::Location; + pub type Number = f32; #[derive(Debug, Clone, PartialEq)] @@ -304,7 +305,7 @@ impl Node { matcher, value, flags, - } => (&name, matcher, &value, &flags), + } => (name, matcher, value, flags), _ => panic!("Node is not an attribute selector"), } } @@ -348,7 +349,7 @@ impl Node { pub fn as_dimension(&self) -> (&Number, &String) { match &self.node_type.deref() { - &NodeType::Dimension { value, unit } => (&value, &unit), + &NodeType::Dimension { value, unit } => (value, unit), _ => panic!("Node is not a dimension"), } } @@ -374,7 +375,7 @@ impl Node { property, value, important, - } => (&property, &value, &important), + } => (property, value, important), _ => panic!("Node is not a declaration"), } } diff --git a/crates/gosub_html5/src/parser.rs b/crates/gosub_html5/src/parser.rs index b5057b245..84c31f34b 100644 --- a/crates/gosub_html5/src/parser.rs +++ b/crates/gosub_html5/src/parser.rs @@ -65,39 +65,40 @@ enum InsertionMode { AfterAfterFrameset, } -/// Additional extensions to the Vec type so we can do some stack operations -trait VecExtensions { - fn pop_until(&mut self, f: F) - where - F: FnMut(&T) -> bool; - fn pop_check(&mut self, f: F) -> bool - where - F: FnMut(&T) -> bool; -} - -impl VecExtensions for Vec { - fn pop_until(&mut self, mut f: F) - where - F: FnMut(&NodeId) -> bool, - { - while let Some(top) = self.last() { - if f(top) { - break; - } - self.pop(); - } - } - - fn pop_check(&mut self, mut f: F) -> bool - where - F: FnMut(&NodeId) -> bool, - { - match self.pop() { - Some(popped_value) => f(&popped_value), - None => false, - } - } -} +// /// Additional extensions to the Vec type so we can do some stack operations +// trait VecExtensions { +// fn pop_until(&mut self, f: F) +// where +// F: FnMut(&T) -> bool; +// fn pop_check(&mut self, f: F) -> bool +// where +// F: FnMut(&T) -> bool; +// } +// +// impl VecExtensions for Vec { +// fn pop_until(&mut self, mut f: F) +// where +// F: FnMut(&NodeId) -> bool, +// { +// while let Some(top) = self.last() { +// if f(top) { +// break; +// } +// self.pop(); +// } +// } +// +// fn pop_check(&mut self, mut f: F) -> bool +// where +// F: FnMut(&NodeId) -> bool, +// { +// match self.pop() { +// Some(popped_value) => f(&popped_value), +// None => false, +// } +// } +// } +//TODO: are these still needed? macro_rules! get_node_by_id { ($doc_handle:expr, $id:expr) => { @@ -3741,7 +3742,7 @@ impl<'chars> Html5Parser<'chars> { fn adjust_svg_tag_names(&self, token: &mut Token) { if let Token::StartTag { name, .. } = token { if SVG_ADJUSTMENTS_TAGS.contains_key(name) { - *name = (*SVG_ADJUSTMENTS_TAGS.get(name).expect("svg tagname")).to_owned(); + (*SVG_ADJUSTMENTS_TAGS.get(name).expect("svg tagname")).clone_into(name); } } } diff --git a/crates/gosub_html5/src/parser/document.rs b/crates/gosub_html5/src/parser/document.rs index f32f0049f..2ec11194e 100755 --- a/crates/gosub_html5/src/parser/document.rs +++ b/crates/gosub_html5/src/parser/document.rs @@ -889,11 +889,20 @@ impl DocumentHandle { pub fn deep_clone(&self) -> DocumentHandle { let mut doc_handle = Document::shared(None); - doc_handle.get_mut().location = self.get().location.clone(); - doc_handle.get_mut().named_id_elements = self.get().named_id_elements.clone(); + doc_handle + .get_mut() + .location + .clone_from(&self.get().location); + doc_handle + .get_mut() + .named_id_elements + .clone_from(&self.get().named_id_elements); doc_handle.get_mut().doctype = self.get().doctype; doc_handle.get_mut().quirks_mode = self.get().quirks_mode; - doc_handle.get_mut().stylesheets = self.get().stylesheets.clone(); + doc_handle + .get_mut() + .stylesheets + .clone_from(&self.get().stylesheets); doc_handle.get_mut().arena = self.get().arena.clone(); doc_handle @@ -965,7 +974,9 @@ impl DocumentBuilder { } // Copy location - doc.get_mut().location = doc_get.borrow().location.clone(); + doc.get_mut() + .location + .clone_from(&doc_get.borrow().location); } // @TODO: Set tokenizer state based on context element @@ -1299,8 +1310,8 @@ mod tests { // validate that invalid changes did not apply to DOM let doc_read = document.get(); - assert!(doc_read.named_id_elements.get("my id").is_none()); - assert!(doc_read.named_id_elements.get("").is_none()); + assert!(!doc_read.named_id_elements.contains_key("my id")); + assert!(!doc_read.named_id_elements.contains_key("")); } // this is basically a replica of document_task_queue() test diff --git a/crates/gosub_jsapi/src/console.rs b/crates/gosub_jsapi/src/console.rs index 1d5c671e4..7fa8c9a8a 100755 --- a/crates/gosub_jsapi/src/console.rs +++ b/crates/gosub_jsapi/src/console.rs @@ -161,8 +161,8 @@ impl Console { /// Create a counter named "label" pub fn count(&mut self, label: &str) { let mut cnt = 1; - if self.count_map.contains_key(&label.to_owned()) { - cnt = self.count_map.get(&label.to_owned()).unwrap() + 1; + if self.count_map.contains_key(label) { + cnt = self.count_map.get(label).unwrap() + 1; } self.count_map.insert(label.to_owned(), cnt); @@ -173,7 +173,7 @@ impl Console { /// Reset count of the given label to 0 pub fn count_reset(&mut self, label: &str) { - if !self.count_map.contains_key(&label.to_owned()) { + if !self.count_map.contains_key(label) { self.logger(LogLevel::CountReset, &[&"label does not exist"]); return; } @@ -225,7 +225,7 @@ impl Console { /// Create a timer with given label pub fn time(&mut self, label: &str) { - if self.timer_map.contains_key(&label.to_owned()) { + if self.timer_map.contains_key(label) { let warning = format!("Timer '{label}' already started"); self.logger(LogLevel::Warn, &[&warning]); return; @@ -262,7 +262,7 @@ impl Console { let concat = format!( "{}: {}ms{}", label.to_owned(), - cur - self.timer_map.get(&label.to_owned()).unwrap().start, + cur - self.timer_map.get(label).unwrap().start, message ); self.printer.print(LogLevel::TimeLog, &[&concat], &[]); @@ -278,7 +278,7 @@ impl Console { let concat = format!( "{}: {}ms", label.to_owned(), - end - self.timer_map.get(&label.to_owned()).unwrap().start + end - self.timer_map.get(label).unwrap().start ); self.printer.print(LogLevel::TimeEnd, &[&concat], &[]); } diff --git a/crates/gosub_jsapi/src/console/writable_printer.rs b/crates/gosub_jsapi/src/console/writable_printer.rs index 2fee89928..2fd30aa70 100755 --- a/crates/gosub_jsapi/src/console/writable_printer.rs +++ b/crates/gosub_jsapi/src/console/writable_printer.rs @@ -66,7 +66,7 @@ impl Printer for WritablePrinter { for arg in args { data.push_str(format!("{arg} ").as_str()); } - data = data.trim_end().to_owned(); + data = data.trim_end().to_string(); let mut writer = self.writer.borrow_mut(); let _ = match log_level { diff --git a/crates/gosub_net/src/dns.rs b/crates/gosub_net/src/dns.rs index ced17cb76..0eb1f837a 100644 --- a/crates/gosub_net/src/dns.rs +++ b/crates/gosub_net/src/dns.rs @@ -101,6 +101,7 @@ trait DnsResolver { fn name(&self) -> &'static str; } +#[allow(dead_code)] trait DnsCache { /// Flush all domains fn flush_all(&mut self); diff --git a/crates/gosub_webinterop/src/types.rs b/crates/gosub_webinterop/src/types.rs index c409ba008..137219396 100644 --- a/crates/gosub_webinterop/src/types.rs +++ b/crates/gosub_webinterop/src/types.rs @@ -1,7 +1,4 @@ -use std::fmt::Debug; - pub(crate) use args::*; -use executor::Executor; pub(crate) use field::*; pub(crate) use generics::*; pub(crate) use primitive::*; @@ -15,8 +12,9 @@ mod primitive; mod slice; mod ty; -#[derive(Clone, PartialEq, Debug)] -pub(crate) struct PropertyOptions { - pub(crate) executor: Executor, - pub(crate) rename: Option, -} +// #[derive(Clone, PartialEq, Debug)] +// pub(crate) struct PropertyOptions { +// pub(crate) executor: Executor, +// pub(crate) rename: Option, +// } +//TODO: is this still needed?