Skip to content

Commit

Permalink
Fixed clippy warnings (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorKoenders authored Dec 10, 2021
1 parent d3a51a9 commit 1401776
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions derive/src/derive_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ impl DeriveStruct {
fn_body
.push_parsed(format!(
"bincode::Encode::encode(&bincode::serde::Compat(&self.{}), &mut encoder)?;",
field.to_string()
field
))
.unwrap();
} else {
fn_body
.push_parsed(format!(
"bincode::enc::Encode::encode(&self.{}, &mut encoder)?;",
field.to_string()
field
))
.unwrap();
}
Expand Down Expand Up @@ -72,14 +72,14 @@ impl DeriveStruct {
struct_body
.push_parsed(format!(
"{}: (<bincode::serde::Compat<_> as bincode::Decode>::decode(&mut decoder)?).0,",
field.to_string()
field
))
.unwrap();
} else {
struct_body
.push_parsed(format!(
"{}: bincode::Decode::decode(&mut decoder)?,",
field.to_string()
field
))
.unwrap();
}
Expand Down Expand Up @@ -114,14 +114,14 @@ impl DeriveStruct {
struct_body
.push_parsed(format!(
"{}: (<bincode::serde::BorrowCompat<_> as bincode::de::BorrowDecode>::borrow_decode(&mut decoder)?).0,",
field.to_string()
field
))
.unwrap();
} else {
struct_body
.push_parsed(format!(
"{}: bincode::de::BorrowDecode::borrow_decode(&mut decoder)?,",
field.to_string()
field
))
.unwrap();
}
Expand Down
12 changes: 6 additions & 6 deletions derive/src/parse/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Generics {
#[derive(Debug)]
enum Generic {
Lifetime(Lifetime),
Generic(SimpleGeneric),
Simple(SimpleGeneric),
Const(ConstGeneric),
}

Expand All @@ -136,7 +136,7 @@ impl Generic {
fn ident(&self) -> Ident {
match self {
Self::Lifetime(lt) => lt.ident.clone(),
Self::Generic(gen) => gen.ident.clone(),
Self::Simple(gen) => gen.ident.clone(),
Self::Const(gen) => gen.ident.clone(),
}
}
Expand All @@ -151,23 +151,23 @@ impl Generic {
fn has_constraints(&self) -> bool {
match self {
Self::Lifetime(lt) => !lt.constraint.is_empty(),
Self::Generic(gen) => !gen.constraints.is_empty(),
Self::Simple(gen) => !gen.constraints.is_empty(),
Self::Const(_) => true, // const generics always have a constraint
}
}

fn constraints(&self) -> Vec<TokenTree> {
match self {
Self::Lifetime(lt) => lt.constraint.clone(),
Self::Generic(gen) => gen.constraints.clone(),
Self::Simple(gen) => gen.constraints.clone(),
Self::Const(gen) => gen.constraints.clone(),
}
}

fn append_to_result_with_constraints(&self, builder: &mut StreamBuilder) {
match self {
Self::Lifetime(lt) => builder.lifetime(lt.ident.clone()),
Self::Generic(gen) => {
Self::Simple(gen) => {
builder.ident(gen.ident.clone());
}
Self::Const(gen) => {
Expand All @@ -190,7 +190,7 @@ impl From<Lifetime> for Generic {

impl From<SimpleGeneric> for Generic {
fn from(gen: SimpleGeneric) -> Self {
Self::Generic(gen)
Self::Simple(gen)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/de/impl_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
// SAFETY: this slice will contain only initialized objects.
unsafe {
core::ptr::drop_in_place(slice_assume_init_mut(
&mut self.array_mut.get_unchecked_mut(..self.initialized),
self.array_mut.get_unchecked_mut(..self.initialized),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/enc/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'storage> Writer for SliceWriter<'storage> {
if bytes.len() > self.slice.len() {
return Err(EncodeError::UnexpectedEnd);
}
let (a, b) = core::mem::replace(&mut self.slice, &mut []).split_at_mut(bytes.len());
let (a, b) = core::mem::take(&mut self.slice).split_at_mut(bytes.len());
a.copy_from_slice(bytes);
self.slice = b;

Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#![doc(html_root_url = "https://docs.rs/bincode/2.0.0-alpha.1")]
#![crate_name = "bincode"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down

0 comments on commit 1401776

Please sign in to comment.