Skip to content

Convert a bunch of lifetimes to '_ due to clippy now recommending this #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nftnl/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ pub struct Iter<'a> {

// Safety: It should be safe to pass this around and *read* from it
// from multiple threads.
unsafe impl<'a> Send for Iter<'a> {}
unsafe impl<'a> Sync for Iter<'a> {}
unsafe impl Send for Iter<'_> {}
unsafe impl Sync for Iter<'_> {}

impl<'a> Iterator for Iter<'a> {
type Item = &'a [u8];
Expand Down
10 changes: 5 additions & 5 deletions nftnl/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ pub struct Chain<'a> {

// Safety: It should be safe to pass this around and *read* from it
// from multiple threads
unsafe impl<'a> Send for Chain<'a> {}
unsafe impl<'a> Sync for Chain<'a> {}
unsafe impl Send for Chain<'_> {}
unsafe impl Sync for Chain<'_> {}

impl<'a> Chain<'a> {
/// Creates a new chain instance inside the given [`Table`] and with the given name.
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<'a> Chain<'a> {
}
}

impl<'a> fmt::Debug for Chain<'a> {
impl fmt::Debug for Chain<'_> {
/// Return a string representation of the chain.
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut buffer: [u8; 4096] = [0; 4096];
Expand All @@ -167,7 +167,7 @@ impl<'a> fmt::Debug for Chain<'a> {
}
}

unsafe impl<'a> crate::NlMsg for Chain<'a> {
unsafe impl crate::NlMsg for Chain<'_> {
unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType) {
let raw_msg_type = match msg_type {
MsgType::Add => libc::NFT_MSG_NEWCHAIN,
Expand All @@ -188,7 +188,7 @@ unsafe impl<'a> crate::NlMsg for Chain<'a> {
}
}

impl<'a> Drop for Chain<'a> {
impl Drop for Chain<'_> {
fn drop(&mut self) {
unsafe { sys::nftnl_chain_free(self.chain) };
}
Expand Down
8 changes: 4 additions & 4 deletions nftnl/src/expr/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ impl ToSlice for [u8; 0] {
}
}

impl<'a> ToSlice for &'a [u8] {
impl ToSlice for &'_ [u8] {
fn to_slice(&self) -> Cow<'_, [u8]> {
Cow::Borrowed(self)
}
}

impl<'a> ToSlice for &'a [u16] {
impl ToSlice for &'_ [u16] {
fn to_slice(&self) -> Cow<'_, [u8]> {
let ptr = self.as_ptr() as *const u8;
let len = self.len() * 2;
Expand Down Expand Up @@ -186,7 +186,7 @@ impl ToSlice for i32 {
}
}

impl<'a> ToSlice for &'a str {
impl ToSlice for &'_ str {
fn to_slice(&self) -> Cow<'_, [u8]> {
Cow::from(self.as_bytes())
}
Expand Down Expand Up @@ -218,7 +218,7 @@ impl ToSlice for InterfaceName {
}
}

impl<'a> ToSlice for &'a InterfaceName {
impl ToSlice for &'_ InterfaceName {
fn to_slice(&self) -> Cow<'_, [u8]> {
let bytes = match *self {
InterfaceName::Exact(ref name) => name.as_bytes_with_nul(),
Expand Down
8 changes: 4 additions & 4 deletions nftnl/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub struct Rule<'a> {

// Safety: It should be safe to pass this around and *read* from it
// from multiple threads
unsafe impl<'a> Send for Rule<'a> {}
unsafe impl<'a> Sync for Rule<'a> {}
unsafe impl Send for Rule<'_> {}
unsafe impl Sync for Rule<'_> {}

impl<'a> Rule<'a> {
/// Creates a new rule object in the given [`Chain`].
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'a> Rule<'a> {
}
}

unsafe impl<'a> crate::NlMsg for Rule<'a> {
unsafe impl crate::NlMsg for Rule<'_> {
unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType) {
let type_ = match msg_type {
MsgType::Add => libc::NFT_MSG_NEWRULE,
Expand All @@ -91,7 +91,7 @@ unsafe impl<'a> crate::NlMsg for Rule<'a> {
}
}

impl<'a> Drop for Rule<'a> {
impl Drop for Rule<'_> {
fn drop(&mut self) {
unsafe { sys::nftnl_rule_free(self.rule) };
}
Expand Down
8 changes: 4 additions & 4 deletions nftnl/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a, K> Set<'a, K> {
}
}

unsafe impl<'a, K> crate::NlMsg for Set<'a, K> {
unsafe impl<K> crate::NlMsg for Set<'_, K> {
unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType) {
let type_ = match msg_type {
MsgType::Add => libc::NFT_MSG_NEWSET,
Expand All @@ -123,7 +123,7 @@ unsafe impl<'a, K> crate::NlMsg for Set<'a, K> {
}
}

impl<'a, K> Drop for Set<'a, K> {
impl<K> Drop for Set<'_, K> {
fn drop(&mut self) {
unsafe { sys::nftnl_set_free(self.set) };
}
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<'a, K: 'a> Iterator for SetElemsIter<'a, K> {
}
}

impl<'a, K> Drop for SetElemsIter<'a, K> {
impl<K> Drop for SetElemsIter<'_, K> {
fn drop(&mut self) {
unsafe { sys::nftnl_set_elems_iter_destroy(self.iter) };
}
Expand All @@ -176,7 +176,7 @@ pub struct SetElemsMsg<'a, K> {
ret: Rc<Cell<i32>>,
}

unsafe impl<'a, K> crate::NlMsg for SetElemsMsg<'a, K> {
unsafe impl<K> crate::NlMsg for SetElemsMsg<'_, K> {
unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType) {
trace!("Writing SetElemsMsg to NlMsg");
let (type_, flags) = match msg_type {
Expand Down
Loading