diff --git a/src/bin/foliabenchmarkr.rs b/src/bin/foliabenchmarkr.rs index 8c2dd11..48d3136 100644 --- a/src/bin/foliabenchmarkr.rs +++ b/src/bin/foliabenchmarkr.rs @@ -15,7 +15,7 @@ pub struct Rusage(libc::rusage); pub type Errno = os::raw::c_int; fn get_resource_usage(who: os::raw::c_int) -> Result { - let mut data = unsafe { mem::uninitialized() }; + let mut data = unsafe { mem::MaybeUninit::uninit().assume_init() }; let result = unsafe { libc::getrusage(who, &mut data) }; @@ -106,6 +106,7 @@ fn test(test_id: &str, filename: &str) { for _element in doc.select(selector, Recursion::Always) { count += 1; } + println!("{}",count); m.end(test_id, filename, "Parse XML from file into full memory representation"); doc.id(); //just to make sure the compiler doesn't optimise doc away (not sure if needed but better safe than sorry) }, diff --git a/src/document.rs b/src/document.rs index e02860b..066c882 100644 --- a/src/document.rs +++ b/src/document.rs @@ -487,7 +487,7 @@ impl Document { } } if let Some(prockey) = self.active_processor { - if let Some(mut declaration) = self.get_mut_declaration(declaration_key.expect("get deckey")) { + if let Some(declaration) = self.get_mut_declaration(declaration_key.expect("get deckey")) { if !declaration.processors.contains(&prockey) { declaration.processors.push(prockey); } @@ -826,7 +826,7 @@ impl Store for Document { let annotationtype = parent.elementtype.annotationtype().expect(format!("Unwrapping annotation type of parent {}", element.elementtype).as_str() ); let deckey = self.declare(annotationtype, &element.set().unwrap().map(|s| s.to_string()), &None, &None)?; - declaration_key = Some(deckey);; + declaration_key = Some(deckey); if let Some(declaration) = self.get_mut_declaration(deckey) { if let Ok(Some(class)) = element.class() { diff --git a/src/error.rs b/src/error.rs index 75695ee..176d56a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -78,10 +78,10 @@ impl From for FoliaError { } } -impl Error for FoliaError { - fn description(&self) -> &str { +impl FoliaError { + fn as_str(&self) -> &str { match *self { - FoliaError::IoError(ref err) => err.description(), + FoliaError::IoError(ref _err) => "IO Error", FoliaError::XmlError(ref _err) => "XML Error", FoliaError::ParseError(ref _err) => "Parse Error", FoliaError::SerialisationError(ref _err) => "Serialisation Error", @@ -96,6 +96,9 @@ impl Error for FoliaError { FoliaError::IndexError => "invalid index", } } +} + +impl Error for FoliaError { fn cause(&self) -> Option<&dyn Error> { match *self { @@ -131,7 +134,7 @@ impl fmt::Display for FoliaError { FoliaError::QueryError(ref err) | FoliaError::TypeError(ref err) | FoliaError::KeyError(ref err) => { - write!(f, "[{}] {}", self.description(), err) + write!(f, "[{}] {}", self.as_str(), err) } FoliaError::IndexError => fmt::Display::fmt("invalid index", f), } diff --git a/src/serialiser.rs b/src/serialiser.rs index a177543..128c497 100644 --- a/src/serialiser.rs +++ b/src/serialiser.rs @@ -213,7 +213,7 @@ impl Document { let mut last_start: String = "".to_string(); for item in self.select_data_by_key(root_key,Selector::all_data(),Recursion::Always, true, false) { while item.depth < previous_depth { - if let Some((end,elementtype,tagstring)) = stack.pop() { + if let Some((end,elementtype,_tagstring)) = stack.pop() { writer.write_event(Event::End(end)).map_err(to_serialisation_error)?; if !ElementGroup::TextMarkup.contains(elementtype) { writer.write_event(Event::Text(BytesText::from_plain(NL))).map_err(to_serialisation_error)?; @@ -300,7 +300,7 @@ impl Document { } //don't forget the final closing elements - while let Some((end, _elementtype, tagstring)) = stack.pop() { + while let Some((end, _elementtype, _tagstring)) = stack.pop() { writer.write_event(Event::End(end)).map_err(to_serialisation_error)?; //eprintln!("[DEBUG] <-- Popped final end tag {}", tagstring.as_str()); } diff --git a/src/store.rs b/src/store.rs index e43fd0d..9dfd452 100644 --- a/src/store.rs +++ b/src/store.rs @@ -29,7 +29,7 @@ pub trait Storable { } ///Set the key of the current item (if supported by the item) - fn assign_key(&mut self, key: Key) { + fn assign_key(&mut self, _key: Key) { //does nothing by default, override in implementations } @@ -49,7 +49,7 @@ pub trait Store where T: Storable, fn iter(&self) -> std::slice::Iter>>; fn index(&self) -> &HashMap; - fn encode(&mut self, mut item: T, context: Option) -> Result { + fn encode(&mut self, item: T, _context: Option) -> Result { Ok(item) //we assume the item does not need to be decoded by default } diff --git a/src/text.rs b/src/text.rs index fd80e31..150e25d 100644 --- a/src/text.rs +++ b/src/text.rs @@ -61,7 +61,6 @@ impl<'a> Element<'a> { ///Returns the text content of a given element pub fn text_by_key(&self, set: DecKey, textclass: ClassKey, strict: bool, retaintokenisation: bool, previousdelimiter: Option) -> Result { let doc = self.document().ok_or(FoliaError::KeyError("Element has no associated document".to_string()))?; - let key = self.key().ok_or(FoliaError::KeyError("Element has no key".to_string()))?; let properties = doc.props(self.elementtype());