Fix clippy warnings

Signed-off-by: Jim Crossley <jim@crossleys.org>
This commit is contained in:
Jim Crossley 2021-06-28 11:47:27 -04:00
parent bf21c52869
commit c1715d75a4
4 changed files with 10 additions and 12 deletions

View File

@ -120,8 +120,7 @@ impl fmt::Display for Event {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "CloudEvent:")?; writeln!(f, "CloudEvent:")?;
self.iter() self.iter()
.map(|(name, val)| writeln!(f, " {}: '{}'", name, val)) .try_for_each(|(name, val)| writeln!(f, " {}: '{}'", name, val))?;
.collect::<fmt::Result>()?;
match self.data() { match self.data() {
Some(data) => write!(f, " {}", data)?, Some(data) => write!(f, " {}", data)?,
None => write!(f, " No data")?, None => write!(f, " No data")?,

View File

@ -54,9 +54,9 @@ impl fmt::Display for MessageAttributeValue {
} }
} }
impl Into<MessageAttributeValue> for ExtensionValue { impl From<ExtensionValue> for MessageAttributeValue {
fn into(self) -> MessageAttributeValue { fn from(that: ExtensionValue) -> Self {
match self { match that {
ExtensionValue::String(s) => MessageAttributeValue::String(s), ExtensionValue::String(s) => MessageAttributeValue::String(s),
ExtensionValue::Boolean(b) => MessageAttributeValue::Boolean(b), ExtensionValue::Boolean(b) => MessageAttributeValue::Boolean(b),
ExtensionValue::Integer(i) => MessageAttributeValue::Integer(i), ExtensionValue::Integer(i) => MessageAttributeValue::Integer(i),
@ -64,9 +64,9 @@ impl Into<MessageAttributeValue> for ExtensionValue {
} }
} }
impl Into<ExtensionValue> for MessageAttributeValue { impl From<MessageAttributeValue> for ExtensionValue {
fn into(self) -> ExtensionValue { fn from(that: MessageAttributeValue) -> Self {
match self { match that {
MessageAttributeValue::Integer(i) => ExtensionValue::Integer(i), MessageAttributeValue::Integer(i) => ExtensionValue::Integer(i),
MessageAttributeValue::Boolean(b) => ExtensionValue::Boolean(b), MessageAttributeValue::Boolean(b) => ExtensionValue::Boolean(b),
v => ExtensionValue::String(v.to_string()), v => ExtensionValue::String(v.to_string()),

View File

@ -63,7 +63,7 @@ impl BinaryDeserializer for RequestDeserializer {
)? )?
} }
if self.body.len() != 0 { if !self.body.is_empty() {
visitor.end_with_data(self.body.to_vec()) visitor.end_with_data(self.body.to_vec())
} else { } else {
visitor.end() visitor.end()

View File

@ -84,8 +84,7 @@ impl BinarySerializer<Response> for ResponseSerializer {
impl StructuredSerializer<Response> for ResponseSerializer { impl StructuredSerializer<Response> for ResponseSerializer {
fn set_structured_event(self, bytes: Vec<u8>) -> Result<Response> { fn set_structured_event(self, bytes: Vec<u8>) -> Result<Response> {
Ok(self self.builder
.builder
.header( .header(
http::header::CONTENT_TYPE, http::header::CONTENT_TYPE,
headers::CLOUDEVENTS_JSON_HEADER.clone(), headers::CLOUDEVENTS_JSON_HEADER.clone(),
@ -93,7 +92,7 @@ impl StructuredSerializer<Response> for ResponseSerializer {
.body(Body::from(bytes)) .body(Body::from(bytes))
.map_err(|e| crate::message::Error::Other { .map_err(|e| crate::message::Error::Other {
source: Box::new(e), source: Box::new(e),
})?) })
} }
} }