Mercurial > crates > nonstick
diff libpam-sys/src/helpers.rs @ 134:6c1e1bdb4164
Use standard #[cfg] directives rather than custom proc macros.
Instead of having to do a bunch of custom parsing and other logic
that tools often choke on, this change introduces an easy way
to depend upon custom #[cfg]s provided by the libpam-sys crate.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 03 Jul 2025 11:03:36 -0400 |
parents | c77846f3a979 |
children |
line wrap: on
line diff
--- a/libpam-sys/src/helpers.rs Wed Jul 02 03:33:09 2025 -0400 +++ b/libpam-sys/src/helpers.rs Thu Jul 03 11:03:36 2025 -0400 @@ -1,7 +1,6 @@ //! This module contains a few non-required helpers to deal with some of the //! more annoying memory management in the PAM API. -use super::cfg_pam_impl; use std::error::Error; use std::marker::{PhantomData, PhantomPinned}; use std::mem::ManuallyDrop; @@ -133,30 +132,6 @@ slice::from_raw_parts(*ptr_ptr.cast(), count).iter() } - #[cfg_pam_impl("LinuxPam")] - unsafe fn _iter_over<'a, Src>( - ptr_ptr: *const *const Src, - count: usize, - ) -> impl Iterator<Item = &'a T> - where - T: 'a, - { - #[allow(deprecated)] - Self::iter_over_linux(ptr_ptr, count) - } - - #[cfg_pam_impl(not("LinuxPam"))] - unsafe fn _iter_over<'a, Src>( - ptr_ptr: *const *const Src, - count: usize, - ) -> impl Iterator<Item = &'a T> - where - T: 'a, - { - #[allow(deprecated)] - Self::iter_over_xsso(ptr_ptr, count) - } - /// Iterates over a PAM message list appropriate to your system's impl. /// /// This selects the correct pointer/array structure to use for a message @@ -166,6 +141,7 @@ /// /// `ptr_ptr` must point to a valid message list, there must be at least /// `count` messages in the list, and all messages must be a valid `Src`. + #[allow(deprecated)] pub unsafe fn iter_over<'a, Src>( ptr_ptr: *const *const Src, count: usize, @@ -173,7 +149,10 @@ where T: 'a, { - Self::_iter_over(ptr_ptr, count) + #[cfg(pam_impl = "LinuxPam")] + return Self::iter_over_linux(ptr_ptr, count); + #[cfg(not(pam_impl = "LinuxPam"))] + return Self::iter_over_xsso(ptr_ptr, count); } fn assert_size<That>() {