Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mcatanzariti committed Jan 17, 2025
1 parent 9e71995 commit 69a12a0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 64 deletions.
1 change: 0 additions & 1 deletion src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ impl Client {
/// Ok(())
/// }
/// ```
#[inline]
pub async fn send(&self, command: Command, retry_on_error: Option<bool>) -> Result<RespBuf> {
let (result_sender, result_receiver): (ResultSender, ResultReceiver) = oneshot::channel();
Expand Down
50 changes: 25 additions & 25 deletions src/client/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Pipeline<'a> {
retry_on_error: Option<bool>,
}

impl<'a> Pipeline<'a> {
impl Pipeline<'_> {
pub(crate) fn new(client: &Client) -> Pipeline {
Pipeline {
client,
Expand Down Expand Up @@ -131,7 +131,7 @@ pub trait BatchPreparedCommand<R = ()> {
fn forget(self);
}

impl<'a, 'b, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut Pipeline<'b>, R> {
impl<'a, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut Pipeline<'_>, R> {
/// Queue a command.
#[inline]
fn queue(self) {
Expand All @@ -145,44 +145,44 @@ impl<'a, 'b, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut P
}
}

impl<'a, 'b> BitmapCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> BitmapCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
impl<'a, 'b> BloomCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> ClusterCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> ConnectionCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> BloomCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> ClusterCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> ConnectionCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
impl<'a, 'b> CountMinSketchCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> CountMinSketchCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
impl<'a, 'b> CuckooCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> GenericCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> GeoCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> CuckooCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> GenericCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> GeoCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
impl<'a, 'b> GraphCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> HashCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> HyperLogLogCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> GraphCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> HashCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> HyperLogLogCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-json")))]
#[cfg(feature = "redis-json")]
impl<'a, 'b> JsonCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> ListCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> JsonCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> ListCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-search")))]
#[cfg(feature = "redis-search")]
impl<'a, 'b> SearchCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> SetCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> ScriptingCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> ServerCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> SortedSetCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> StreamCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a, 'b> StringCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> SearchCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> SetCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> ScriptingCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> ServerCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> SortedSetCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> StreamCommands<'a> for &'a mut Pipeline<'_> {}
impl<'a> StringCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
impl<'a, 'b> TDigestCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> TDigestCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-time-series")))]
#[cfg(feature = "redis-time-series")]
impl<'a, 'b> TimeSeriesCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> TimeSeriesCommands<'a> for &'a mut Pipeline<'_> {}
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
impl<'a, 'b> TopKCommands<'a> for &'a mut Pipeline<'b> {}
impl<'a> TopKCommands<'a> for &'a mut Pipeline<'_> {}
2 changes: 1 addition & 1 deletion src/commands/cluster_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub trait ClusterCommands<'a> {
/// In Redis Cluster, each node keeps track of which master is serving a particular hash slot.
/// This command asks a particular Redis Cluster node to forget which master
/// is serving the hash slots specified as arguments.
///
/// # See Also
/// [<https://redis.io/commands/cluster-delslots/>](https://redis.io/commands/cluster-delslots/)
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/commands/string_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub trait StringCommands<'a> {
/// So -1 means the last character, -2 the penultimate and so forth.
///
/// The function handles out of range requests by limiting the resulting range to the actual length of the string.
///
/// # See Also
/// [<https://redis.io/commands/getrange/>](https://redis.io/commands/getrange/)
#[must_use]
Expand Down
16 changes: 3 additions & 13 deletions src/network/reconnection_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ impl ReconnectionState {
max_attempts,
jitter,
} => {
self.attempts = match incr_with_max(self.attempts, *max_attempts) {
Some(a) => a,
None => return None,
};

self.attempts = incr_with_max(self.attempts, *max_attempts)?;
Some(add_jitter(*delay as u64, *jitter))
}
ReconnectionConfig::Linear {
Expand All @@ -41,10 +37,7 @@ impl ReconnectionState {
delay,
jitter,
} => {
self.attempts = match incr_with_max(self.attempts, *max_attempts) {
Some(a) => a,
None => return None,
};
self.attempts = incr_with_max(self.attempts, *max_attempts)?;
let delay = (*delay as u64).saturating_mul(self.attempts as u64);

Some(cmp::min(*max_delay as u64, add_jitter(delay, *jitter)))
Expand All @@ -56,10 +49,7 @@ impl ReconnectionState {
multiplicative_factor,
jitter,
} => {
self.attempts = match incr_with_max(self.attempts, *max_attempts) {
Some(a) => a,
None => return None,
};
self.attempts = incr_with_max(self.attempts, *max_attempts)?;
let delay = (*multiplicative_factor as u64)
.saturating_pow(self.attempts - 1)
.saturating_mul(*min_delay as u64);
Expand Down
2 changes: 1 addition & 1 deletion src/network/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum RefPubSubMessage<'a> {
SMessage(&'a [u8], &'a [u8]),
}

impl<'a> std::fmt::Debug for RefPubSubMessage<'a> {
impl std::fmt::Debug for RefPubSubMessage<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Subscribe(arg0) => f
Expand Down
26 changes: 13 additions & 13 deletions src/resp/resp_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl<'de> RespDeserializer<'de> {
}
}

impl<'de, 'a> Deserializer<'de> for &'a mut RespDeserializer<'de> {
impl<'de> Deserializer<'de> for &mut RespDeserializer<'de> {
type Error = Error;

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>
Expand Down Expand Up @@ -928,7 +928,7 @@ struct SeqAccess<'a, 'de: 'a> {
len: usize,
}

impl<'de, 'a> serde::de::SeqAccess<'de> for SeqAccess<'a, 'de> {
impl<'de> serde::de::SeqAccess<'de> for SeqAccess<'_, 'de> {
type Error = Error;

fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>>
Expand All @@ -949,7 +949,7 @@ impl<'de, 'a> serde::de::SeqAccess<'de> for SeqAccess<'a, 'de> {
}
}

impl<'de, 'a> serde::de::MapAccess<'de> for SeqAccess<'a, 'de> {
impl<'de> serde::de::MapAccess<'de> for SeqAccess<'_, 'de> {
type Error = Error;

fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
Expand Down Expand Up @@ -992,7 +992,7 @@ struct MapAccess<'a, 'de: 'a> {
len: usize,
}

impl<'de, 'a> serde::de::MapAccess<'de> for MapAccess<'a, 'de> {
impl<'de> serde::de::MapAccess<'de> for MapAccess<'_, 'de> {
type Error = Error;

fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
Expand Down Expand Up @@ -1020,7 +1020,7 @@ impl<'de, 'a> serde::de::MapAccess<'de> for MapAccess<'a, 'de> {
}
}

impl<'de, 'a> serde::de::SeqAccess<'de> for MapAccess<'a, 'de> {
impl<'de> serde::de::SeqAccess<'de> for MapAccess<'_, 'de> {
type Error = Error;

fn next_element_seed<T>(
Expand All @@ -1043,7 +1043,7 @@ struct PairDeserializer<'a, 'de: 'a> {
de: &'a mut RespDeserializer<'de>,
}

impl<'de, 'a> Deserializer<'de> for PairDeserializer<'a, 'de> {
impl<'de> Deserializer<'de> for PairDeserializer<'_, 'de> {
type Error = Error;

#[inline]
Expand Down Expand Up @@ -1073,7 +1073,7 @@ impl<'de, 'a> Deserializer<'de> for PairDeserializer<'a, 'de> {
len: usize,
}

impl<'de, 'a> serde::de::SeqAccess<'de> for PairSeqAccess<'a, 'de> {
impl<'de> serde::de::SeqAccess<'de> for PairSeqAccess<'_, 'de> {
type Error = Error;

fn next_element_seed<T>(
Expand All @@ -1100,7 +1100,7 @@ struct Enum<'a, 'de: 'a> {
de: &'a mut RespDeserializer<'de>,
}

impl<'de, 'a> EnumAccess<'de> for Enum<'a, 'de> {
impl<'de> EnumAccess<'de> for Enum<'_, 'de> {
type Error = Error;
type Variant = Self;

Expand All @@ -1114,7 +1114,7 @@ impl<'de, 'a> EnumAccess<'de> for Enum<'a, 'de> {
}
}

impl<'de, 'a> VariantAccess<'de> for Enum<'a, 'de> {
impl<'de> VariantAccess<'de> for Enum<'_, 'de> {
type Error = Error;

// If the `Visitor` expected this variant to be a unit variant, the input
Expand Down Expand Up @@ -1167,7 +1167,7 @@ impl<'de, 'a> PushMapAccess<'de, 'a> {
}
}

impl<'de, 'a> serde::de::MapAccess<'de> for PushMapAccess<'de, 'a> {
impl<'de> serde::de::MapAccess<'de> for PushMapAccess<'de, '_> {
type Error = Error;

fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
Expand Down Expand Up @@ -1215,7 +1215,7 @@ struct PushDeserializer<'de, 'a> {
de: &'a mut RespDeserializer<'de>,
}

impl<'de, 'a> Deserializer<'de> for PushDeserializer<'de, 'a> {
impl<'de> Deserializer<'de> for PushDeserializer<'de, '_> {
type Error = Error;

#[inline]
Expand Down Expand Up @@ -1256,7 +1256,7 @@ impl<'de, 'a> RespArrayChunks<'de, 'a> {
}
}

impl<'de, 'a> Iterator for RespArrayChunks<'de, 'a> {
impl<'de> Iterator for RespArrayChunks<'de, '_> {
type Item = &'de [u8];

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -1276,7 +1276,7 @@ impl<'de, 'a> Iterator for RespArrayChunks<'de, 'a> {
}
}

impl<'de, 'a> ExactSizeIterator for RespArrayChunks<'de, 'a> {
impl ExactSizeIterator for RespArrayChunks<'_, '_> {
#[inline]
fn len(&self) -> usize {
self.len
Expand Down
16 changes: 8 additions & 8 deletions src/resp/resp_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Default for RespSerializer {
}
}

impl<'a> Serializer for &'a mut RespSerializer {
impl Serializer for &mut RespSerializer {
type Ok = ();
type Error = Error;
type SerializeSeq = Self;
Expand Down Expand Up @@ -304,7 +304,7 @@ impl<'a> Serializer for &'a mut RespSerializer {
}
}

impl<'a> SerializeSeq for &'a mut RespSerializer {
impl SerializeSeq for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -322,7 +322,7 @@ impl<'a> SerializeSeq for &'a mut RespSerializer {
}
}

impl<'a> SerializeTuple for &'a mut RespSerializer {
impl SerializeTuple for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -340,7 +340,7 @@ impl<'a> SerializeTuple for &'a mut RespSerializer {
}
}

impl<'a> SerializeTupleStruct for &'a mut RespSerializer {
impl SerializeTupleStruct for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -358,7 +358,7 @@ impl<'a> SerializeTupleStruct for &'a mut RespSerializer {
}
}

impl<'a> SerializeTupleVariant for &'a mut RespSerializer {
impl SerializeTupleVariant for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -376,7 +376,7 @@ impl<'a> SerializeTupleVariant for &'a mut RespSerializer {
}
}

impl<'a> SerializeMap for &'a mut RespSerializer {
impl SerializeMap for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -402,7 +402,7 @@ impl<'a> SerializeMap for &'a mut RespSerializer {
}
}

impl<'a> SerializeStruct for &'a mut RespSerializer {
impl SerializeStruct for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand All @@ -421,7 +421,7 @@ impl<'a> SerializeStruct for &'a mut RespSerializer {
}
}

impl<'a> SerializeStructVariant for &'a mut RespSerializer {
impl SerializeStructVariant for &mut RespSerializer {
type Ok = ();
type Error = Error;

Expand Down
2 changes: 1 addition & 1 deletion src/resp/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
{
struct ByteBufVisitor;

impl<'de> Visitor<'de> for ByteBufVisitor {
impl Visitor<'_> for ByteBufVisitor {
type Value = Vec<u8>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down

0 comments on commit 69a12a0

Please sign in to comment.