diff --git a/parsers/ChangeLog b/parsers/ChangeLog index cd5d4b54d4b429bbf3df2359e275eff6399134a5..47d79f2aec002a20b51bb6339b632edc596ef8c9 100644 --- a/parsers/ChangeLog +++ b/parsers/ChangeLog @@ -90,6 +90,7 @@ XXXX-YY-ZZ RELEASER - Add Message::get_best_body_cloned and Message::get_best_subject_cloned to clone automatically when performance is not an issue (!497) - Fix compatibility to uuid 1.12 + - Implement Default for Tune Version 0.21.0: 2024-07-25 Emmanuel Gil Peyrot diff --git a/parsers/src/date.rs b/parsers/src/date.rs index 8a488ad67d303e29db75f7d10758202fa0e48978..dd5f99f963b9b936d04b61d9d7bfa0cc61e195af 100644 --- a/parsers/src/date.rs +++ b/parsers/src/date.rs @@ -19,7 +19,7 @@ pub struct Xep0082; impl TextCodec> for Xep0082 { fn decode(&self, s: String) -> Result, Error> { - Ok(ChronoDateTime::parse_from_rfc3339(&s).map_err(Error::text_parse_error)?) + ChronoDateTime::parse_from_rfc3339(&s).map_err(Error::text_parse_error) } fn encode<'x>( diff --git a/parsers/src/http_upload.rs b/parsers/src/http_upload.rs index fb276fd58f197b6c92a160be151d3560e792abd0..47770b16185ef31ac29fa2e47507238567473d6f 100644 --- a/parsers/src/http_upload.rs +++ b/parsers/src/http_upload.rs @@ -63,8 +63,7 @@ impl FromXmlText for HeaderName { _ => { return Err(Error::Other( "Header name must be either 'Authorization', 'Cookie', or 'Expires'.", - ) - .into()) + )) } }) } diff --git a/parsers/src/iq.rs b/parsers/src/iq.rs index edca5bb157af4c13bb489034963c735716efc3ec..6caff133665120ec7fb0694c02ac7a2d7b796e50 100644 --- a/parsers/src/iq.rs +++ b/parsers/src/iq.rs @@ -37,7 +37,7 @@ pub enum IqType { Error(StanzaError), } -impl<'a> IntoAttributeValue for &'a IqType { +impl IntoAttributeValue for &IqType { fn into_attribute_value(self) -> Option { Some( match *self { diff --git a/parsers/src/stream_error.rs b/parsers/src/stream_error.rs index b4c9715567f9e29f5055401e533306c44e15500d..ad2f1500efaef4c811f066ccaff42f68611373b8 100644 --- a/parsers/src/stream_error.rs +++ b/parsers/src/stream_error.rs @@ -320,15 +320,11 @@ pub struct StreamError { impl fmt::Display for StreamError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(&self.condition, f)?; - match self.text { - Some((_, ref text)) => write!(f, " ({:?})", text)?, - None => (), - }; - match self.application_specific.get(0) { - Some(cond) => { - f.write_str(&String::from(cond))?; - } - None => (), + if let Some((_, ref text)) = self.text { + write!(f, " ({:?})", text)? + } + if let Some(cond) = self.application_specific.first() { + f.write_str(&String::from(cond))?; } Ok(()) } diff --git a/parsers/src/time.rs b/parsers/src/time.rs index 73a359805c88ffdbf119fcc831589e2d4d9d6226..9092512d5d43761c0fce66e5d0178ebb34025492 100644 --- a/parsers/src/time.rs +++ b/parsers/src/time.rs @@ -19,7 +19,7 @@ struct ColonSeparatedOffset; impl TextCodec for ColonSeparatedOffset { fn decode(&self, s: String) -> Result { - Ok(FixedOffset::from_str(&s).map_err(Error::text_parse_error)?) + FixedOffset::from_str(&s).map_err(Error::text_parse_error) } fn encode<'x>(&self, value: &'x FixedOffset) -> Result>, Error> { @@ -69,7 +69,7 @@ impl From for DateTime { impl From for DateTime { fn from(time: TimeResult) -> Self { - time.utc.into() + time.utc } } @@ -77,10 +77,7 @@ impl From> for TimeResult { fn from(dt: DateTime) -> Self { let tz_offset = *dt.offset(); let utc = dt.with_timezone(&Utc); - TimeResult { - tz_offset, - utc: utc.into(), - } + TimeResult { tz_offset, utc } } } @@ -88,7 +85,7 @@ impl From> for TimeResult { fn from(dt: DateTime) -> Self { TimeResult { tz_offset: FixedOffset::east_opt(0).unwrap(), - utc: dt.into(), + utc: dt, } } } diff --git a/parsers/src/tune.rs b/parsers/src/tune.rs index d27cf5ebcce643bad0e6b92feadf088345ce7b20..1441b3ae1d08f1140f005e7dc97ef6092c0e25e0 100644 --- a/parsers/src/tune.rs +++ b/parsers/src/tune.rs @@ -114,6 +114,12 @@ impl Tune { } } +impl Default for Tune { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/parsers/src/xhtml.rs b/parsers/src/xhtml.rs index 28cd30648a0d4240ad684dbf319085a437b9318f..bc7bb8698c16affe8b3d55cf4a300f53087d8f00 100644 --- a/parsers/src/xhtml.rs +++ b/parsers/src/xhtml.rs @@ -25,6 +25,8 @@ impl XhtmlIm { pub fn into_html(self) -> String { let mut html = Vec::new(); // TODO: use the best language instead. + // XXX: Remove this flag later when fixing the code below + #[allow(clippy::never_loop)] for (lang, body) in self.bodies { if lang.is_empty() { assert!(body.xml_lang.is_none());