Detailed changes
@@ -90,6 +90,7 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
- 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 <linkmauve@linkmauve.fr>
@@ -19,7 +19,7 @@ pub struct Xep0082;
impl TextCodec<ChronoDateTime<FixedOffset>> for Xep0082 {
fn decode(&self, s: String) -> Result<ChronoDateTime<FixedOffset>, 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>(
@@ -63,8 +63,7 @@ impl FromXmlText for HeaderName {
_ => {
return Err(Error::Other(
"Header name must be either 'Authorization', 'Cookie', or 'Expires'.",
- )
- .into())
+ ))
}
})
}
@@ -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<String> {
Some(
match *self {
@@ -320,15 +320,11 @@ pub struct StreamError {
impl fmt::Display for StreamError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<DefinedCondition as fmt::Display>::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(())
}
@@ -19,7 +19,7 @@ struct ColonSeparatedOffset;
impl TextCodec<FixedOffset> for ColonSeparatedOffset {
fn decode(&self, s: String) -> Result<FixedOffset, Error> {
- 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<Option<Cow<'x, str>>, Error> {
@@ -69,7 +69,7 @@ impl From<TimeResult> for DateTime<FixedOffset> {
impl From<TimeResult> for DateTime<Utc> {
fn from(time: TimeResult) -> Self {
- time.utc.into()
+ time.utc
}
}
@@ -77,10 +77,7 @@ impl From<DateTime<FixedOffset>> for TimeResult {
fn from(dt: DateTime<FixedOffset>) -> 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<DateTime<Utc>> for TimeResult {
fn from(dt: DateTime<Utc>) -> Self {
TimeResult {
tz_offset: FixedOffset::east_opt(0).unwrap(),
- utc: dt.into(),
+ utc: dt,
}
}
}
@@ -114,6 +114,12 @@ impl Tune {
}
}
+impl Default for Tune {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -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());