xso: Fix all clippy warnings
This commit is contained in:
parent
69f480e709
commit
b18385cfff
3 changed files with 15 additions and 18 deletions
|
@ -276,9 +276,8 @@ pub fn transform<T: FromXml, F: IntoXml>(from: F) -> Result<T, self::error::Erro
|
|||
};
|
||||
for event in iter {
|
||||
let event = event?;
|
||||
match sink.feed(event)? {
|
||||
Some(v) => return Ok(v),
|
||||
None => (),
|
||||
if let Some(v) = sink.feed(event)? {
|
||||
return Ok(v);
|
||||
}
|
||||
}
|
||||
Err(self::error::Error::XmlError(
|
||||
|
@ -312,9 +311,8 @@ pub fn try_from_element<T: FromXml>(
|
|||
iter.next().expect("first event from minidom::Element")?;
|
||||
for event in iter {
|
||||
let event = event?;
|
||||
match sink.feed(event)? {
|
||||
Some(v) => return Ok(v),
|
||||
None => (),
|
||||
if let Some(v) = sink.feed(event)? {
|
||||
return Ok(v);
|
||||
}
|
||||
}
|
||||
// unreachable! instead of error here, because minidom::Element always
|
||||
|
@ -368,9 +366,8 @@ pub fn from_bytes<T: FromXml>(mut buf: &[u8]) -> Result<T, self::error::Error> {
|
|||
Err(self::error::FromEventsError::Invalid(e)) => return Err(e),
|
||||
};
|
||||
for ev in reader {
|
||||
match builder.feed(map_nonio_error(ev)?)? {
|
||||
Some(v) => return Ok(v),
|
||||
None => (),
|
||||
if let Some(v) = builder.feed(map_nonio_error(ev)?)? {
|
||||
return Ok(v);
|
||||
}
|
||||
}
|
||||
Err(self::error::Error::XmlError(
|
||||
|
|
|
@ -96,7 +96,7 @@ impl IntoEventsInner {
|
|||
remaining: el.take_nodes().into_iter(),
|
||||
nested: None,
|
||||
};
|
||||
return Ok(Some(event));
|
||||
Ok(Some(event))
|
||||
}
|
||||
IntoEventsInner::Nodes {
|
||||
ref mut nested,
|
||||
|
@ -213,7 +213,7 @@ impl FromXml for Element {
|
|||
let mut builder = Element::builder(qname.1, qname.0);
|
||||
for ((namespace, name), value) in attrs.into_iter() {
|
||||
if namespace.is_none() {
|
||||
builder = builder.attr(name, String::from(value));
|
||||
builder = builder.attr(name, value);
|
||||
} else {
|
||||
let (is_new, prefix) = prefixes.declare_with_auto_prefix(namespace.clone());
|
||||
let name = prefix.with_suffix(&name);
|
||||
|
@ -225,7 +225,7 @@ impl FromXml for Element {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
builder = builder.attr(name, String::from(value));
|
||||
builder = builder.attr(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ pub struct EmptyAsNone;
|
|||
|
||||
impl TextCodec<Option<String>> for EmptyAsNone {
|
||||
fn decode(s: String) -> Result<Option<String>, Error> {
|
||||
if s.len() == 0 {
|
||||
if s.is_empty() {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(s))
|
||||
|
@ -160,7 +160,7 @@ impl TextCodec<Option<String>> for EmptyAsNone {
|
|||
|
||||
fn encode(value: Option<String>) -> Result<Option<String>, Error> {
|
||||
Ok(match value {
|
||||
Some(v) if v.len() > 0 => Some(v),
|
||||
Some(v) if !v.is_empty() => Some(v),
|
||||
Some(_) | None => None,
|
||||
})
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ pub struct Base64<Filter: TextFilter = NoFilter>(PhantomData<Filter>);
|
|||
impl<Filter: TextFilter> TextCodec<Vec<u8>> for Base64<Filter> {
|
||||
fn decode(s: String) -> Result<Vec<u8>, Error> {
|
||||
let value = Filter::preprocess(s);
|
||||
Ok(StandardBase64Engine
|
||||
.decode(value.as_str().as_bytes())
|
||||
.map_err(Error::text_parse_error)?)
|
||||
StandardBase64Engine
|
||||
.decode(value.as_bytes())
|
||||
.map_err(Error::text_parse_error)
|
||||
}
|
||||
|
||||
fn encode(value: Vec<u8>) -> Result<Option<String>, Error> {
|
||||
|
@ -224,7 +224,7 @@ impl<Filter: TextFilter> TextCodec<Vec<u8>> for Base64<Filter> {
|
|||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
|
||||
impl<Filter: TextFilter> TextCodec<Option<Vec<u8>>> for Base64<Filter> {
|
||||
fn decode(s: String) -> Result<Option<Vec<u8>>, Error> {
|
||||
if s.len() == 0 {
|
||||
if s.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
Ok(Some(Self::decode(s)?))
|
||||
|
|
Loading…
Reference in a new issue