parsers: clippy run

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2025-04-07 21:53:22 +02:00
commit 1b635854ad
8 changed files with 21 additions and 20 deletions

View file

@ -90,6 +90,7 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
- Add Message::get_best_body_cloned and Message::get_best_subject_cloned - Add Message::get_best_body_cloned and Message::get_best_subject_cloned
to clone automatically when performance is not an issue (!497) to clone automatically when performance is not an issue (!497)
- Fix compatibility to uuid 1.12 - Fix compatibility to uuid 1.12
- Implement Default for Tune
Version 0.21.0: Version 0.21.0:
2024-07-25 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> 2024-07-25 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

View file

@ -19,7 +19,7 @@ pub struct Xep0082;
impl TextCodec<ChronoDateTime<FixedOffset>> for Xep0082 { impl TextCodec<ChronoDateTime<FixedOffset>> for Xep0082 {
fn decode(&self, s: String) -> Result<ChronoDateTime<FixedOffset>, Error> { 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>( fn encode<'x>(

View file

@ -63,8 +63,7 @@ impl FromXmlText for HeaderName {
_ => { _ => {
return Err(Error::Other( return Err(Error::Other(
"Header name must be either 'Authorization', 'Cookie', or 'Expires'.", "Header name must be either 'Authorization', 'Cookie', or 'Expires'.",
) ))
.into())
} }
}) })
} }

View file

@ -37,7 +37,7 @@ pub enum IqType {
Error(StanzaError), Error(StanzaError),
} }
impl<'a> IntoAttributeValue for &'a IqType { impl IntoAttributeValue for &IqType {
fn into_attribute_value(self) -> Option<String> { fn into_attribute_value(self) -> Option<String> {
Some( Some(
match *self { match *self {

View file

@ -320,15 +320,11 @@ pub struct StreamError {
impl fmt::Display for StreamError { impl fmt::Display for StreamError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<DefinedCondition as fmt::Display>::fmt(&self.condition, f)?; <DefinedCondition as fmt::Display>::fmt(&self.condition, f)?;
match self.text { if let Some((_, ref text)) = self.text {
Some((_, ref text)) => write!(f, " ({:?})", text)?, write!(f, " ({:?})", text)?
None => (), }
}; if let Some(cond) = self.application_specific.first() {
match self.application_specific.get(0) { f.write_str(&String::from(cond))?;
Some(cond) => {
f.write_str(&String::from(cond))?;
}
None => (),
} }
Ok(()) Ok(())
} }

View file

@ -19,7 +19,7 @@ struct ColonSeparatedOffset;
impl TextCodec<FixedOffset> for ColonSeparatedOffset { impl TextCodec<FixedOffset> for ColonSeparatedOffset {
fn decode(&self, s: String) -> Result<FixedOffset, Error> { 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> { 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> { impl From<TimeResult> for DateTime<Utc> {
fn from(time: TimeResult) -> Self { 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 { fn from(dt: DateTime<FixedOffset>) -> Self {
let tz_offset = *dt.offset(); let tz_offset = *dt.offset();
let utc = dt.with_timezone(&Utc); let utc = dt.with_timezone(&Utc);
TimeResult { TimeResult { tz_offset, utc }
tz_offset,
utc: utc.into(),
}
} }
} }
@ -88,7 +85,7 @@ impl From<DateTime<Utc>> for TimeResult {
fn from(dt: DateTime<Utc>) -> Self { fn from(dt: DateTime<Utc>) -> Self {
TimeResult { TimeResult {
tz_offset: FixedOffset::east_opt(0).unwrap(), tz_offset: FixedOffset::east_opt(0).unwrap(),
utc: dt.into(), utc: dt,
} }
} }
} }

View file

@ -114,6 +114,12 @@ impl Tune {
} }
} }
impl Default for Tune {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -25,6 +25,8 @@ impl XhtmlIm {
pub fn into_html(self) -> String { pub fn into_html(self) -> String {
let mut html = Vec::new(); let mut html = Vec::new();
// TODO: use the best language instead. // 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 { for (lang, body) in self.bodies {
if lang.is_empty() { if lang.is_empty() {
assert!(body.xml_lang.is_none()); assert!(body.xml_lang.is_none());