make clippy happy

This commit is contained in:
Alex 2022-11-18 16:29:18 +01:00
parent 1bcefaa1ae
commit bcef147633
Signed by: lx
GPG key ID: 0E496D15096376BE
2 changed files with 16 additions and 12 deletions

View file

@ -28,7 +28,7 @@ where
{
let term = decode(s)?;
let mut deserializer = Deserializer::from_term(&term);
Ok(T::deserialize(&mut deserializer)?)
T::deserialize(&mut deserializer)
}
// ----
@ -133,7 +133,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de, 'a> {
let mut chars = s.chars();
let c = chars
.next()
.ok_or(Error::custom("invalid char: empty string"))?;
.ok_or_else(|| Error::custom("invalid char: empty string"))?;
if chars.next().is_some() {
Err(Error::custom("invalid char: too many chars"))
} else {
@ -376,11 +376,13 @@ impl<'de, 'a> MapAccess<'de> for &'a mut Dict<'de, 'a> {
where
V: DeserializeSeed<'de>,
{
let k = self.1.ok_or(Error::custom("invald mapaccess order"))?;
let k = self
.1
.ok_or_else(|| Error::custom("invald mapaccess order"))?;
let v = self
.0
.get(k)
.ok_or(Error::custom("invald mapaccess order"))?;
.ok_or_else(|| Error::custom("invald mapaccess order"))?;
seed.deserialize(&mut Deserializer(Term(v.mkref())))
}
}

View file

@ -10,7 +10,7 @@ pub fn to_term<T>(value: &T) -> Result<Term<'static>>
where
T: Serialize,
{
Ok(value.serialize(&mut Serializer)?)
value.serialize(&mut Serializer)
}
pub fn to_bytes<T>(value: &T) -> Result<Vec<u8>>
@ -210,7 +210,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
pub struct SeqSerializer {
items: Vec<Term<'static>>,
}
impl<'a> ser::SerializeSeq for SeqSerializer {
impl ser::SerializeSeq for SeqSerializer {
type Ok = Term<'static>;
type Error = Error;
@ -227,7 +227,7 @@ impl<'a> ser::SerializeSeq for SeqSerializer {
}
}
impl<'a> ser::SerializeTuple for SeqSerializer {
impl ser::SerializeTuple for SeqSerializer {
type Ok = Term<'static>;
type Error = Error;
@ -244,7 +244,7 @@ impl<'a> ser::SerializeTuple for SeqSerializer {
}
}
impl<'a> ser::SerializeTupleStruct for SeqSerializer {
impl ser::SerializeTupleStruct for SeqSerializer {
type Ok = Term<'static>;
type Error = Error;
@ -261,7 +261,7 @@ impl<'a> ser::SerializeTupleStruct for SeqSerializer {
}
}
impl<'a> ser::SerializeTupleVariant for SeqSerializer {
impl ser::SerializeTupleVariant for SeqSerializer {
type Ok = Term<'static>;
type Error = Error;
@ -283,7 +283,7 @@ pub struct MapSerializer {
fields: Vec<(Vec<u8>, Term<'static>)>,
}
impl<'a> ser::SerializeMap for MapSerializer {
impl ser::SerializeMap for MapSerializer {
type Ok = Term<'static>;
type Error = Error;
@ -300,7 +300,9 @@ impl<'a> ser::SerializeMap for MapSerializer {
T: ?Sized + Serialize,
{
self.fields.push((
self.next.take().ok_or(Self::Error::custom("no key"))?,
self.next
.take()
.ok_or_else(|| Self::Error::custom("no key"))?,
value.serialize(&mut Serializer)?,
));
Ok(())
@ -339,7 +341,7 @@ pub struct StructVariantSerializer {
fields: Vec<(&'static str, Term<'static>)>,
}
impl<'a> ser::SerializeStructVariant for StructVariantSerializer {
impl ser::SerializeStructVariant for StructVariantSerializer {
type Ok = Term<'static>;
type Error = Error;