mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
run clippy fix
This commit is contained in:
@@ -62,13 +62,13 @@ impl<T: XmlRootTag + XmlDeserialize> XmlDocument for T {
|
||||
format!("{root_ns:?}"),
|
||||
Self::root_tag().to_owned(),
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
return Self::deserialize(&mut reader, &start, empty);
|
||||
}
|
||||
Event::Eof => return Err(XmlError::Eof),
|
||||
_ => return Err(XmlError::UnsupportedEvent("unknown, todo")),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ impl XmlDeserialize for () {
|
||||
Event::End(e) if e.name() == start.name() => return Ok(()),
|
||||
Event::Eof => return Err(XmlError::Eof),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use quick_xml::name::Namespace;
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct NamespaceOwned(pub Vec<u8>);
|
||||
|
||||
impl<'a> From<Namespace<'a>> for NamespaceOwned {
|
||||
@@ -28,7 +28,7 @@ impl<'a> From<&'a Namespace<'a>> for NamespaceOwned {
|
||||
}
|
||||
|
||||
impl NamespaceOwned {
|
||||
pub fn as_ref(&self) -> Namespace<'_> {
|
||||
#[must_use] pub fn as_ref(&self) -> Namespace<'_> {
|
||||
Namespace(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +65,12 @@ impl XmlSerialize for () {
|
||||
writer: &mut quick_xml::Writer<&mut Vec<u8>>,
|
||||
) -> std::io::Result<()> {
|
||||
let prefix = ns
|
||||
.map(|ns| namespaces.get(&ns))
|
||||
.unwrap_or(None)
|
||||
.and_then(|ns| namespaces.get(&ns))
|
||||
.map(|prefix| {
|
||||
if !prefix.is_empty() {
|
||||
[*prefix, ":"].concat()
|
||||
} else {
|
||||
if prefix.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
[*prefix, ":"].concat()
|
||||
}
|
||||
});
|
||||
let has_prefix = prefix.is_some();
|
||||
|
||||
@@ -5,11 +5,11 @@ use quick_xml::events::BytesStart;
|
||||
use crate::{XmlDeserialize, XmlError};
|
||||
|
||||
// TODO: actually implement
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Unparsed(BytesStart<'static>);
|
||||
|
||||
impl Unparsed {
|
||||
pub fn tag_name(&self) -> String {
|
||||
#[must_use] pub fn tag_name(&self) -> String {
|
||||
// TODO: respect namespace?
|
||||
String::from_utf8_lossy(self.0.local_name().as_ref()).to_string()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl_value_parse!(usize);
|
||||
|
||||
impl ValueSerialize for &str {
|
||||
fn serialize(&self) -> String {
|
||||
self.to_string()
|
||||
(*self).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ impl<T: ValueDeserialize> XmlDeserialize for T {
|
||||
Event::End(_) => break,
|
||||
Event::Eof => return Err(XmlError::Eof),
|
||||
_ => return Err(XmlError::UnsupportedEvent("todo")),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,13 +115,12 @@ impl<T: ValueSerialize> XmlSerialize for T {
|
||||
writer: &mut quick_xml::Writer<&mut Vec<u8>>,
|
||||
) -> std::io::Result<()> {
|
||||
let prefix = ns
|
||||
.map(|ns| namespaces.get(&ns))
|
||||
.unwrap_or(None)
|
||||
.and_then(|ns| namespaces.get(&ns))
|
||||
.map(|prefix| {
|
||||
if !prefix.is_empty() {
|
||||
[*prefix, ":"].concat()
|
||||
} else {
|
||||
if prefix.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
[*prefix, ":"].concat()
|
||||
}
|
||||
});
|
||||
let has_prefix = prefix.is_some();
|
||||
|
||||
Reference in New Issue
Block a user