Skip to content

Commit 7fb2443

Browse files
authored
Merge pull request #53 from najamelan/fix_clippy_warnings
Fix clippy warnings.
2 parents f507444 + 6f97af9 commit 7fb2443

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/codec/cbor.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ where
156156
}
157157
}
158158

159+
impl<Enc, Dec> Default for CborCodec<Enc, Dec>
160+
where
161+
for<'de> Dec: Deserialize<'de> + 'static,
162+
for<'de> Enc: Serialize + 'static,
163+
{
164+
fn default() -> Self {
165+
Self::new()
166+
}
167+
}
168+
159169
#[cfg(test)]
160170
mod test {
161171
use bytes::BytesMut;
@@ -198,7 +208,7 @@ mod test {
198208
name: "Test name".to_owned(),
199209
data: 34,
200210
};
201-
codec.encode(item1.clone(), &mut buff).unwrap();
211+
codec.encode(item1, &mut buff).unwrap();
202212

203213
let mut start = buff.clone().split_to(4);
204214
assert_eq!(codec.decode(&mut start).unwrap(), None);

src/codec/json.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::{Decoder, Encoder};
44
use bytes::{Buf, BufMut, BytesMut};
55

66
use serde::{Deserialize, Serialize};
7-
use serde_json;
87

98
/// A codec for JSON encoding and decoding using serde_json
109
/// Enc is the type to encode, Dec is the type to decode
@@ -154,6 +153,18 @@ where
154153
}
155154
}
156155

156+
157+
impl<Enc, Dec> Default for JsonCodec<Enc, Dec>
158+
where
159+
for<'de> Dec: Deserialize<'de> + 'static,
160+
for<'de> Enc: Serialize + 'static,
161+
{
162+
fn default() -> Self {
163+
Self::new()
164+
}
165+
}
166+
167+
157168
#[cfg(test)]
158169
mod test {
159170
use bytes::BytesMut;
@@ -196,7 +207,7 @@ mod test {
196207
name: "Test name".to_owned(),
197208
data: 34,
198209
};
199-
codec.encode(item1.clone(), &mut buff).unwrap();
210+
codec.encode(item1, &mut buff).unwrap();
200211

201212
let mut start = buff.clone().split_to(4);
202213
assert_eq!(codec.decode(&mut start).unwrap(), None);

0 commit comments

Comments
 (0)