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
|
fn_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"bincode::Encode::encode(&bincode::serde::Compat(&self.{}), &mut encoder)?;",
|
"bincode::Encode::encode(&bincode::serde::Compat(&self.{}), &mut encoder)?;",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
fn_body
|
fn_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"bincode::enc::Encode::encode(&self.{}, &mut encoder)?;",
|
"bincode::enc::Encode::encode(&self.{}, &mut encoder)?;",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -72,14 +72,14 @@ impl DeriveStruct {
|
||||||
struct_body
|
struct_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"{}: (<bincode::serde::Compat<_> as bincode::Decode>::decode(&mut decoder)?).0,",
|
"{}: (<bincode::serde::Compat<_> as bincode::Decode>::decode(&mut decoder)?).0,",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
struct_body
|
struct_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"{}: bincode::Decode::decode(&mut decoder)?,",
|
"{}: bincode::Decode::decode(&mut decoder)?,",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -114,14 +114,14 @@ impl DeriveStruct {
|
||||||
struct_body
|
struct_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"{}: (<bincode::serde::BorrowCompat<_> as bincode::de::BorrowDecode>::borrow_decode(&mut decoder)?).0,",
|
"{}: (<bincode::serde::BorrowCompat<_> as bincode::de::BorrowDecode>::borrow_decode(&mut decoder)?).0,",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
struct_body
|
struct_body
|
||||||
.push_parsed(format!(
|
.push_parsed(format!(
|
||||||
"{}: bincode::de::BorrowDecode::borrow_decode(&mut decoder)?,",
|
"{}: bincode::de::BorrowDecode::borrow_decode(&mut decoder)?,",
|
||||||
field.to_string()
|
field
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ impl Generics {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Generic {
|
enum Generic {
|
||||||
Lifetime(Lifetime),
|
Lifetime(Lifetime),
|
||||||
Generic(SimpleGeneric),
|
Simple(SimpleGeneric),
|
||||||
Const(ConstGeneric),
|
Const(ConstGeneric),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ impl Generic {
|
||||||
fn ident(&self) -> Ident {
|
fn ident(&self) -> Ident {
|
||||||
match self {
|
match self {
|
||||||
Self::Lifetime(lt) => lt.ident.clone(),
|
Self::Lifetime(lt) => lt.ident.clone(),
|
||||||
Self::Generic(gen) => gen.ident.clone(),
|
Self::Simple(gen) => gen.ident.clone(),
|
||||||
Self::Const(gen) => gen.ident.clone(),
|
Self::Const(gen) => gen.ident.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ impl Generic {
|
||||||
fn has_constraints(&self) -> bool {
|
fn has_constraints(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Lifetime(lt) => !lt.constraint.is_empty(),
|
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
|
Self::Const(_) => true, // const generics always have a constraint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +159,7 @@ impl Generic {
|
||||||
fn constraints(&self) -> Vec<TokenTree> {
|
fn constraints(&self) -> Vec<TokenTree> {
|
||||||
match self {
|
match self {
|
||||||
Self::Lifetime(lt) => lt.constraint.clone(),
|
Self::Lifetime(lt) => lt.constraint.clone(),
|
||||||
Self::Generic(gen) => gen.constraints.clone(),
|
Self::Simple(gen) => gen.constraints.clone(),
|
||||||
Self::Const(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) {
|
fn append_to_result_with_constraints(&self, builder: &mut StreamBuilder) {
|
||||||
match self {
|
match self {
|
||||||
Self::Lifetime(lt) => builder.lifetime(lt.ident.clone()),
|
Self::Lifetime(lt) => builder.lifetime(lt.ident.clone()),
|
||||||
Self::Generic(gen) => {
|
Self::Simple(gen) => {
|
||||||
builder.ident(gen.ident.clone());
|
builder.ident(gen.ident.clone());
|
||||||
}
|
}
|
||||||
Self::Const(gen) => {
|
Self::Const(gen) => {
|
||||||
|
|
@ -190,7 +190,7 @@ impl From<Lifetime> for Generic {
|
||||||
|
|
||||||
impl From<SimpleGeneric> for Generic {
|
impl From<SimpleGeneric> for Generic {
|
||||||
fn from(gen: SimpleGeneric) -> Self {
|
fn from(gen: SimpleGeneric) -> Self {
|
||||||
Self::Generic(gen)
|
Self::Simple(gen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ where
|
||||||
// SAFETY: this slice will contain only initialized objects.
|
// SAFETY: this slice will contain only initialized objects.
|
||||||
unsafe {
|
unsafe {
|
||||||
core::ptr::drop_in_place(slice_assume_init_mut(
|
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() {
|
if bytes.len() > self.slice.len() {
|
||||||
return Err(EncodeError::UnexpectedEnd);
|
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);
|
a.copy_from_slice(bytes);
|
||||||
self.slice = b;
|
self.slice = b;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@
|
||||||
#![doc(html_root_url = "https://docs.rs/bincode/2.0.0-alpha.1")]
|
#![doc(html_root_url = "https://docs.rs/bincode/2.0.0-alpha.1")]
|
||||||
#![crate_name = "bincode"]
|
#![crate_name = "bincode"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![crate_type = "dylib"]
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue