Skip to content

Commit

Permalink
Address clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Crossley <jim@crossleys.org>
  • Loading branch information
jcrossley3 committed Nov 4, 2022
1 parent 7c2ff41 commit c6a84b3
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/binding/actix/server_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod tests {
use serde_json::json;

async fn to_event(req: &HttpRequest, mut payload: Payload) -> Event {
web::Payload::from_request(&req, &mut payload)
web::Payload::from_request(req, &mut payload)
.then(|p| req.to_event(p.unwrap()))
.await
.unwrap()
Expand Down Expand Up @@ -120,7 +120,7 @@ mod tests {
.insert_header(("ce-int_ex", "10"))
.insert_header(("ce-bool_ex", "true"))
.insert_header(("content-type", "application/json"))
.set_json(&fixtures::json_data())
.set_json(fixtures::json_data())
.to_http_parts();

assert_eq!(expected, to_event(&req, payload).await);
Expand Down
2 changes: 1 addition & 1 deletion src/binding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! header_value_to_str {
($header_value:expr) => {
$header_value
.to_str()
.map_err(|e| crate::message::Error::Other {
.map_err(|e| $crate::message::Error::Other {
source: Box::new(e),
})
};
Expand Down
4 changes: 2 additions & 2 deletions src/binding/nats/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod tests {
let nats_message = nats::Message::new(
"not_relevant",
None,
json!(expected.clone()).to_string().as_bytes().to_vec(),
json!(expected).to_string().as_bytes(),
None,
);

Expand All @@ -66,7 +66,7 @@ mod tests {
let nats_message = nats::Message::new(
"not_relevant",
None,
json!(expected.clone()).to_string().as_bytes().to_vec(),
json!(expected).to_string().as_bytes(),
None,
);

Expand Down
2 changes: 1 addition & 1 deletion src/binding/nats/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct NatsCloudEvent {

impl AsRef<[u8]> for NatsCloudEvent {
fn as_ref(&self) -> &[u8] {
&self.payload.as_ref()
self.payload.as_ref()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/binding/poem/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod tests {
.header("ce-string_ex", "val")
.header("ce-int_ex", "10")
.header("ce-bool_ex", "true")
.header("ce-time", &fixtures::time().to_rfc3339())
.header("ce-time", fixtures::time().to_rfc3339())
.body(fixtures::json_data_binary());
let (req, mut body) = req.split();
let result = Event::from_request(&req, &mut body).await.unwrap();
Expand Down
5 changes: 2 additions & 3 deletions src/binding/rdkafka/kafka_consumer_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl BinaryDeserializer for ConsumerRecordDeserializer {
}
}

if self.payload != None {
if self.payload.is_some() {
visitor.end_with_data(self.payload.unwrap())
} else {
visitor.end()
Expand All @@ -116,8 +116,7 @@ impl MessageDeserializer for ConsumerRecordDeserializer {
match (
self.headers
.get("content-type")
.map(|s| String::from_utf8(s.to_vec()).ok())
.flatten()
.and_then(|s| String::from_utf8(s.to_vec()).ok())
.map(|s| s.starts_with(CLOUDEVENTS_JSON_HEADER))
.unwrap_or(false),
self.headers.get(SPEC_VERSION_HEADER),
Expand Down
3 changes: 1 addition & 2 deletions src/event/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ pub(crate) fn default_hostname() -> Url {
"http://{}",
hostname::get()
.ok()
.map(|s| s.into_string().ok())
.flatten()
.and_then(|s| s.into_string().ok())
.unwrap_or_else(|| "localhost".to_string())
)
.as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion src/event/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn parse_data_string<E: serde::de::Error>(v: Value) -> Result<String, E> {

pub fn parse_data_base64<E: serde::de::Error>(v: Value) -> Result<Vec<u8>, E> {
parse_field!(v, String, E).and_then(|s| {
base64::decode(&s).map_err(|e| E::custom(format_args!("decode error `{}`", e)))
base64::decode(s).map_err(|e| E::custom(format_args!("decode error `{}`", e)))
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/fixtures/v03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn full_json_base64_data_json() -> Value {
"datacontenttype": json_datacontenttype(),
"schemaurl": dataschema(),
"datacontentencoding": "base64",
"data": base64::encode(&json_data_binary())
"data": base64::encode(json_data_binary())
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/fixtures/v10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn full_json_base64_data_json() -> Value {
int_ext_name: int_ext_value,
"datacontenttype": json_datacontenttype(),
"dataschema": dataschema(),
"data_base64": base64::encode(&json_data_binary())
"data_base64": base64::encode(json_data_binary())
})
}

Expand Down

0 comments on commit c6a84b3

Please sign in to comment.