Lines Matching +full:union +full:- +full:value
12 pub(crate) const fn as_ptr<T>(t: &T) -> *const T { in as_ptr()
18 pub(crate) fn as_mut_ptr<T>(t: &mut T) -> *mut T { in as_mut_ptr()
22 /// Convert an `Option<&T>` into a possibly-null `*const T`.
24 pub(crate) const fn option_as_ptr<T>(t: Option<&T>) -> *const T { in option_as_ptr()
31 /// Convert an `Option<&mut T>` into a possibly-null `*mut T`.
33 pub(crate) fn option_as_mut_ptr<T>(t: Option<&mut T>) -> *mut T { in option_as_mut_ptr()
43 pub(crate) fn check_raw_pointer<T>(value: *mut c_void) -> Option<NonNull<T>> { in check_raw_pointer()
44 if (value as usize).checked_add(size_of::<T>()).is_none() in check_raw_pointer()
45 || (value as usize) % align_of::<T>() != 0 in check_raw_pointer()
50 NonNull::new(value.cast()) in check_raw_pointer()
53 /// Create an array value containing all default values, inferring the type.
55 pub(crate) fn default_array<T: Default + Copy, const N: usize>() -> [T; N] { in default_array()
59 /// Create a union value containing a default value in one of its arms.
61 /// The field names a union field which must have the same size as the union
64 ($union:ident, $field:ident) => {{
65 let u = $union {
69 // Assert that the given field initializes the whole union.
77 const_assert_eq!(memoffset::offset_of_union!($union, $field), 0);