Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Oct 4, 2024
1 parent 5556e13 commit 6b85743
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 86 deletions.
10 changes: 5 additions & 5 deletions edge-captive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ pub fn reply(

struct Buf<'a>(pub &'a mut [u8], pub usize);

impl<'a> Composer for Buf<'a> {}
impl Composer for Buf<'_> {}

impl<'a> OctetsBuilder for Buf<'a> {
impl OctetsBuilder for Buf<'_> {
type AppendError = ShortBuf;

fn append_slice(&mut self, slice: &[u8]) -> Result<(), Self::AppendError> {
Expand All @@ -145,19 +145,19 @@ impl<'a> OctetsBuilder for Buf<'a> {
}
}

impl<'a> Truncate for Buf<'a> {
impl Truncate for Buf<'_> {
fn truncate(&mut self, len: usize) {
self.1 = len;
}
}

impl<'a> AsMut<[u8]> for Buf<'a> {
impl AsMut<[u8]> for Buf<'_> {
fn as_mut(&mut self) -> &mut [u8] {
&mut self.0[..self.1]
}
}

impl<'a> AsRef<[u8]> for Buf<'a> {
impl AsRef<[u8]> for Buf<'_> {
fn as_ref(&self) -> &[u8] {
&self.0[..self.1]
}
Expand Down
2 changes: 1 addition & 1 deletion edge-dhcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ pub enum DhcpOption<'a> {
Unrecognized(u8, &'a [u8]),
}

impl<'a> DhcpOption<'a> {
impl DhcpOption<'_> {
pub const CODE_ROUTER: u8 = DhcpOption::Router(Ipv4Addrs::new(&[])).code();
pub const CODE_DNS: u8 = DhcpOption::DomainNameServer(Ipv4Addrs::new(&[])).code();
pub const CODE_SUBNET: u8 = DhcpOption::SubnetMask(Ipv4Addr::new(0, 0, 0, 0)).code();
Expand Down
6 changes: 3 additions & 3 deletions edge-http/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ where
}
}

impl<'b, R> ErrorType for Body<'b, R>
impl<R> ErrorType for Body<'_, R>
where
R: ErrorType,
{
Expand Down Expand Up @@ -419,7 +419,7 @@ impl<'b, R> PartiallyRead<'b, R> {
}
}

impl<'b, R> ErrorType for PartiallyRead<'b, R>
impl<R> ErrorType for PartiallyRead<'_, R>
where
R: ErrorType,
{
Expand Down Expand Up @@ -698,7 +698,7 @@ where
}
}

impl<'b, R> ErrorType for ChunkedRead<'b, R>
impl<R> ErrorType for ChunkedRead<'_, R>
where
R: ErrorType,
{
Expand Down
2 changes: 1 addition & 1 deletion edge-http/src/io/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ where
}
}

impl<'b, T, const N: usize> ErrorType for Connection<'b, T, N>
impl<T, const N: usize> ErrorType for Connection<'_, T, N>
where
T: TcpConnect,
{
Expand Down
2 changes: 1 addition & 1 deletion edge-http/src/io/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ where
}
}

impl<'b, T, const N: usize> ErrorType for Connection<'b, T, N>
impl<T, const N: usize> ErrorType for Connection<'_, T, N>
where
T: ErrorType,
{
Expand Down
10 changes: 5 additions & 5 deletions edge-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl<'b, const N: usize> Headers<'b, N> {
}
}

impl<'b, const N: usize> Default for Headers<'b, N> {
impl<const N: usize> Default for Headers<'_, N> {
fn default() -> Self {
Self::new()
}
Expand Down Expand Up @@ -421,7 +421,7 @@ pub struct RequestHeaders<'b, const N: usize> {
pub headers: Headers<'b, N>,
}

impl<'b, const N: usize> RequestHeaders<'b, N> {
impl<const N: usize> RequestHeaders<'_, N> {
#[inline(always)]
pub const fn new() -> Self {
Self {
Expand All @@ -437,7 +437,7 @@ impl<'b, const N: usize> RequestHeaders<'b, N> {
}
}

impl<'b, const N: usize> Display for RequestHeaders<'b, N> {
impl<const N: usize> Display for RequestHeaders<'_, N> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if let Some(http11) = self.http11 {
write!(f, "{} ", if http11 { "HTTP/1.1" } else { "HTTP/1.0" })?;
Expand Down Expand Up @@ -467,7 +467,7 @@ pub struct ResponseHeaders<'b, const N: usize> {
pub headers: Headers<'b, N>,
}

impl<'b, const N: usize> ResponseHeaders<'b, N> {
impl<const N: usize> ResponseHeaders<'_, N> {
#[inline(always)]
pub const fn new() -> Self {
Self {
Expand All @@ -487,7 +487,7 @@ impl<'b, const N: usize> ResponseHeaders<'b, N> {
}
}

impl<'b, const N: usize> Display for ResponseHeaders<'b, N> {
impl<const N: usize> Display for ResponseHeaders<'_, N> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if let Some(http11) = self.http11 {
writeln!(f, "{} ", if http11 { "HTTP/1.1 " } else { "HTTP/1.0" })?;
Expand Down
16 changes: 11 additions & 5 deletions edge-mdns/src/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ where
B: BufferAccess<T>,
T: ?Sized,
{
type Buffer<'a> = B::Buffer<'a> where Self: 'a;
type Buffer<'a>
= B::Buffer<'a>
where
Self: 'a;

async fn get(&self) -> Option<Self::Buffer<'_>> {
(*self).get().await
Expand All @@ -52,7 +55,7 @@ pub struct VecBuf<'a, M, const N: usize>(MutexGuard<'a, M, heapless::Vec<u8, N>>
where
M: RawMutex;

impl<'a, M, const N: usize> Drop for VecBuf<'a, M, N>
impl<M, const N: usize> Drop for VecBuf<'_, M, N>
where
M: RawMutex,
{
Expand All @@ -61,7 +64,7 @@ where
}
}

impl<'a, M, const N: usize> Deref for VecBuf<'a, M, N>
impl<M, const N: usize> Deref for VecBuf<'_, M, N>
where
M: RawMutex,
{
Expand All @@ -72,7 +75,7 @@ where
}
}

impl<'a, M, const N: usize> DerefMut for VecBuf<'a, M, N>
impl<M, const N: usize> DerefMut for VecBuf<'_, M, N>
where
M: RawMutex,
{
Expand All @@ -85,7 +88,10 @@ impl<M, const N: usize> BufferAccess<[u8]> for VecBufAccess<M, N>
where
M: RawMutex,
{
type Buffer<'a> = VecBuf<'a, M, N> where Self: 'a;
type Buffer<'a>
= VecBuf<'a, M, N>
where
Self: 'a;

async fn get(&self) -> Option<Self::Buffer<'_>> {
let mut guard = self.0.lock().await;
Expand Down
8 changes: 4 additions & 4 deletions edge-mdns/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Host<'a> {
pub ttl: Ttl,
}

impl<'a> Host<'a> {
impl Host<'_> {
fn visit_answers<F, E>(&self, mut f: F) -> Result<(), E>
where
F: FnMut(HostAnswer) -> Result<(), E>,
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'a> Host<'a> {
}
}

impl<'a> HostAnswers for Host<'a> {
impl HostAnswers for Host<'_> {
fn visit<F, E>(&self, mut f: F) -> Result<(), E>
where
F: FnMut(HostAnswer) -> Result<(), E>,
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct Service<'a> {
pub txt_kvs: &'a [(&'a str, &'a str)],
}

impl<'a> Service<'a> {
impl Service<'_> {
fn visit_answers<F, E>(&self, host: &Host, mut f: F) -> Result<(), E>
where
F: FnMut(HostAnswer) -> Result<(), E>,
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'a> ServiceAnswers<'a> {
}
}

impl<'a> HostAnswers for ServiceAnswers<'a> {
impl HostAnswers for ServiceAnswers<'_> {
fn visit<F, E>(&self, mut f: F) -> Result<(), E>
where
F: FnMut(HostAnswer) -> Result<(), E>,
Expand Down
40 changes: 23 additions & 17 deletions edge-mdns/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> NameSlice<'a> {
}
}

impl<'a> fmt::Display for NameSlice<'a> {
impl fmt::Display for NameSlice<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for label in self.0 {
write!(f, "{}.", label)?;
Expand All @@ -109,7 +109,7 @@ impl<'a> fmt::Display for NameSlice<'a> {
}
}

impl<'a> ToName for NameSlice<'a> {}
impl ToName for NameSlice<'_> {}

/// An iterator over the labels in a `NameSlice` instance.
#[derive(Clone)]
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<'a> Iterator for NameSliceIter<'a> {
}
}

impl<'a> DoubleEndedIterator for NameSliceIter<'a> {
impl DoubleEndedIterator for NameSliceIter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.index > 0 {
self.index -= 1;
Expand All @@ -155,8 +155,11 @@ impl<'a> DoubleEndedIterator for NameSliceIter<'a> {
}
}

impl<'a> ToLabelIter for NameSlice<'a> {
type LabelIter<'t> = NameSliceIter<'t> where Self: 't;
impl ToLabelIter for NameSlice<'_> {
type LabelIter<'t>
= NameSliceIter<'t>
where
Self: 't;

fn iter_labels(&self) -> Self::LabelIter<'_> {
NameSliceIter {
Expand All @@ -177,7 +180,7 @@ impl<'a> Txt<'a> {
}
}

impl<'a> fmt::Display for Txt<'a> {
impl fmt::Display for Txt<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Txt [")?;

Expand All @@ -195,13 +198,13 @@ impl<'a> fmt::Display for Txt<'a> {
}
}

impl<'a> RecordData for Txt<'a> {
impl RecordData for Txt<'_> {
fn rtype(&self) -> Rtype {
Rtype::TXT
}
}

impl<'a> ComposeRecordData for Txt<'a> {
impl ComposeRecordData for Txt<'_> {
fn rdlen(&self, _compress: bool) -> Option<u16> {
None
}
Expand All @@ -217,7 +220,7 @@ impl<'a> ComposeRecordData for Txt<'a> {
for (k, v) in self.0 {
target.append_slice(&[(k.len() + v.len() + 1) as u8])?;
target.append_slice(k.as_bytes())?;
target.append_slice(&[b'='])?;
target.append_slice(b"=")?;
target.append_slice(v.as_bytes())?;
}
}
Expand Down Expand Up @@ -313,16 +316,19 @@ impl<'a> Buf<'a> {
}
}

impl<'a> FreezeBuilder for Buf<'a> {
impl FreezeBuilder for Buf<'_> {
type Octets = Self;

fn freeze(self) -> Self {
self
}
}

impl<'a> Octets for Buf<'a> {
type Range<'r> = &'r [u8] where Self: 'r;
impl Octets for Buf<'_> {
type Range<'r>
= &'r [u8]
where
Self: 'r;

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_> {
self.0[..self.1].range(range)
Expand All @@ -337,9 +343,9 @@ impl<'a> FromBuilder for Buf<'a> {
}
}

impl<'a> Composer for Buf<'a> {}
impl Composer for Buf<'_> {}

impl<'a> OctetsBuilder for Buf<'a> {
impl OctetsBuilder for Buf<'_> {
type AppendError = ShortBuf;

fn append_slice(&mut self, slice: &[u8]) -> Result<(), Self::AppendError> {
Expand All @@ -355,19 +361,19 @@ impl<'a> OctetsBuilder for Buf<'a> {
}
}

impl<'a> Truncate for Buf<'a> {
impl Truncate for Buf<'_> {
fn truncate(&mut self, len: usize) {
self.1 = len;
}
}

impl<'a> AsMut<[u8]> for Buf<'a> {
impl AsMut<[u8]> for Buf<'_> {
fn as_mut(&mut self) -> &mut [u8] {
&mut self.0[..self.1]
}
}

impl<'a> AsRef<[u8]> for Buf<'a> {
impl AsRef<[u8]> for Buf<'_> {
fn as_ref(&self) -> &[u8] {
&self.0[..self.1]
}
Expand Down
5 changes: 4 additions & 1 deletion edge-mqtt/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ mod embedded_svc_compat {
}

impl Connection for MqttConnection {
type Event<'a> = MqttEvent where Self: 'a;
type Event<'a>
= MqttEvent
where
Self: 'a;

#[allow(clippy::large_futures)]
async fn next(&mut self) -> Result<Self::Event<'_>, Self::Error> {
Expand Down
Loading

0 comments on commit 6b85743

Please sign in to comment.