#[allow(dead_code)]
#[inline(always)]
- pub fn set(&mut self, rhs: Self) {
+ pub const fn set(&mut self, rhs: Self) {
self.0 |= rhs.0;
}
#[allow(dead_code)]
#[inline(always)]
- pub fn clear(&mut self, rhs: Self) {
+ pub const fn clear(&mut self, rhs: Self) {
self.0 &= !rhs.0;
}
#[allow(dead_code)]
#[inline(always)]
- pub fn toggle(&mut self, rhs: Self) {
+ pub const fn toggle(&mut self, rhs: Self) {
self.0 ^= rhs.0;
}
(@internal $param_name:ident, $ti:ty, $t:ty, $($field:tt)*) => {
const _: () = {
#[allow(unused)]
- fn assert_field_type($param_name: &$t) {
- fn types_must_be_equal<T, U>(_: &T)
+ const fn assert_field_type($param_name: &$t) {
+ const fn types_must_be_equal<T, U>(_: &T)
where
T: $crate::assertions::EqType<Itself = U>,
{
/// but the functions containing the dereference are usually safe. The
/// value returned from `uninit()` must be initialized and pinned before
/// calling them.
- #[allow(clippy::missing_const_for_fn)]
- pub unsafe fn uninit() -> Self {
+ pub const unsafe fn uninit() -> Self {
Self {
value: UnsafeCell::new(MaybeUninit::uninit()),
_pin: PhantomPinned,
/// but the functions containing the dereference are usually safe. The
/// value returned from `uninit()` must be pinned (and possibly initialized)
/// before calling them.
- #[allow(clippy::missing_const_for_fn)]
- pub unsafe fn zeroed() -> Self {
+ pub const unsafe fn zeroed() -> Self {
Self {
value: UnsafeCell::new(MaybeUninit::zeroed()),
_pin: PhantomPinned,
/// Fields beyond `Object` could be uninitialized and it's your
/// responsibility to avoid that they're used when the pointer is
/// dereferenced, either directly or through a cast.
- pub fn as_object_mut_ptr(&self) -> *mut bindings::Object {
+ pub const fn as_object_mut_ptr(&self) -> *mut bindings::Object {
self.as_object_ptr().cast_mut()
}
/// Fields beyond `Object` could be uninitialized and it's your
/// responsibility to avoid that they're used when the pointer is
/// dereferenced, either directly or through a cast.
- pub fn as_object_ptr(&self) -> *const bindings::Object {
+ pub const fn as_object_ptr(&self) -> *const bindings::Object {
self.0.as_ptr().cast()
}
}
/// However, while the fields of the resulting reference are initialized,
/// calls might use uninitialized fields of the subclass. It is your
/// responsibility to avoid this.
- pub unsafe fn upcast<U: ObjectType>(&self) -> &'a U
+ pub const unsafe fn upcast<U: ObjectType>(&self) -> &'a U
where
T::ParentType: IsA<U>,
{
///
/// The timer must be initialized before it is armed with
/// [`modify`](Self::modify).
- pub unsafe fn new() -> Self {
+ pub const unsafe fn new() -> Self {
// SAFETY: requirements relayed to callers of Timer::new
Self(unsafe { Opaque::zeroed() })
}
impl<'a, T, U> MaybeUninitField<'a, T, U> {
#[doc(hidden)]
- pub fn new(parent: &'a mut MaybeUninit<T>, child: *mut U) -> Self {
+ pub const fn new(parent: &'a mut MaybeUninit<T>, child: *mut U) -> Self {
MaybeUninitField { parent, child }
}
/// Because the `MaybeUninitField` remembers the containing object,
/// it is possible to use it in foreign APIs that initialize the
/// child.
- pub fn parent(f: &Self) -> *const T {
+ pub const fn parent(f: &Self) -> *const T {
f.parent.as_ptr()
}
/// Because the `MaybeUninitField` remembers the containing object,
/// it is possible to use it in foreign APIs that initialize the
/// child.
- pub fn parent_mut(f: &mut Self) -> *mut T {
+ pub const fn parent_mut(f: &mut Self) -> *mut T {
f.parent.as_mut_ptr()
}
}