mirror of https://git.sr.ht/~stygianentity/bincode
Fixed clippy warnings (#447)
This commit is contained in:
parent
7cb10d4ab3
commit
bb3612103a
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ impl Generics {
|
|||
#[derive(Debug)]
|
||||
enum Generic {
|
||||
Lifetime(Lifetime),
|
||||
Generic(SimpleGeneric),
|
||||
Simple(SimpleGeneric),
|
||||
Const(ConstGeneric),
|
||||
}
|
||||
|
||||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ 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
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ impl Generic {
|
|||
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(),
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ impl Generic {
|
|||
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) => {
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue