Skip to content

Commit c6a84b3

Browse files
committed
Address clippy warnings
Signed-off-by: Jim Crossley <[email protected]>
1 parent 7c2ff41 commit c6a84b3

File tree

10 files changed

+13
-15
lines changed

10 files changed

+13
-15
lines changed

src/binding/actix/server_request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ mod tests {
8484
use serde_json::json;
8585

8686
async fn to_event(req: &HttpRequest, mut payload: Payload) -> Event {
87-
web::Payload::from_request(&req, &mut payload)
87+
web::Payload::from_request(req, &mut payload)
8888
.then(|p| req.to_event(p.unwrap()))
8989
.await
9090
.unwrap()
@@ -120,7 +120,7 @@ mod tests {
120120
.insert_header(("ce-int_ex", "10"))
121121
.insert_header(("ce-bool_ex", "true"))
122122
.insert_header(("content-type", "application/json"))
123-
.set_json(&fixtures::json_data())
123+
.set_json(fixtures::json_data())
124124
.to_http_parts();
125125

126126
assert_eq!(expected, to_event(&req, payload).await);

src/binding/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ macro_rules! header_value_to_str {
6767
($header_value:expr) => {
6868
$header_value
6969
.to_str()
70-
.map_err(|e| crate::message::Error::Other {
70+
.map_err(|e| $crate::message::Error::Other {
7171
source: Box::new(e),
7272
})
7373
};

src/binding/nats/deserializer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod tests {
5050
let nats_message = nats::Message::new(
5151
"not_relevant",
5252
None,
53-
json!(expected.clone()).to_string().as_bytes().to_vec(),
53+
json!(expected).to_string().as_bytes(),
5454
None,
5555
);
5656

@@ -66,7 +66,7 @@ mod tests {
6666
let nats_message = nats::Message::new(
6767
"not_relevant",
6868
None,
69-
json!(expected.clone()).to_string().as_bytes().to_vec(),
69+
json!(expected).to_string().as_bytes(),
7070
None,
7171
);
7272

src/binding/nats/serializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct NatsCloudEvent {
1212

1313
impl AsRef<[u8]> for NatsCloudEvent {
1414
fn as_ref(&self) -> &[u8] {
15-
&self.payload.as_ref()
15+
self.payload.as_ref()
1616
}
1717
}
1818

src/binding/poem/extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mod tests {
7676
.header("ce-string_ex", "val")
7777
.header("ce-int_ex", "10")
7878
.header("ce-bool_ex", "true")
79-
.header("ce-time", &fixtures::time().to_rfc3339())
79+
.header("ce-time", fixtures::time().to_rfc3339())
8080
.body(fixtures::json_data_binary());
8181
let (req, mut body) = req.split();
8282
let result = Event::from_request(&req, &mut body).await.unwrap();

src/binding/rdkafka/kafka_consumer_record.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl BinaryDeserializer for ConsumerRecordDeserializer {
9494
}
9595
}
9696

97-
if self.payload != None {
97+
if self.payload.is_some() {
9898
visitor.end_with_data(self.payload.unwrap())
9999
} else {
100100
visitor.end()
@@ -116,8 +116,7 @@ impl MessageDeserializer for ConsumerRecordDeserializer {
116116
match (
117117
self.headers
118118
.get("content-type")
119-
.map(|s| String::from_utf8(s.to_vec()).ok())
120-
.flatten()
119+
.and_then(|s| String::from_utf8(s.to_vec()).ok())
121120
.map(|s| s.starts_with(CLOUDEVENTS_JSON_HEADER))
122121
.unwrap_or(false),
123122
self.headers.get(SPEC_VERSION_HEADER),

src/event/attributes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ pub(crate) fn default_hostname() -> Url {
259259
"http://{}",
260260
hostname::get()
261261
.ok()
262-
.map(|s| s.into_string().ok())
263-
.flatten()
262+
.and_then(|s| s.into_string().ok())
264263
.unwrap_or_else(|| "localhost".to_string())
265264
)
266265
.as_ref(),

src/event/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn parse_data_string<E: serde::de::Error>(v: Value) -> Result<String, E> {
5858

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

src/test/fixtures/v03.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn full_json_base64_data_json() -> Value {
120120
"datacontenttype": json_datacontenttype(),
121121
"schemaurl": dataschema(),
122122
"datacontentencoding": "base64",
123-
"data": base64::encode(&json_data_binary())
123+
"data": base64::encode(json_data_binary())
124124
})
125125
}
126126

src/test/fixtures/v10.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn full_json_base64_data_json() -> Value {
166166
int_ext_name: int_ext_value,
167167
"datacontenttype": json_datacontenttype(),
168168
"dataschema": dataschema(),
169-
"data_base64": base64::encode(&json_data_binary())
169+
"data_base64": base64::encode(json_data_binary())
170170
})
171171
}
172172

0 commit comments

Comments
 (0)