[−][src]Struct ptr_union::UnionBuilder
A builder for pointer unions that enforces correct alignment.
Currently, because there is no way to generically talk about alignment in the type system, this
requires the use of unsafe
for the programmer to assert that the types are properly aligned.
For that, you get all of the unsafe pointer-wrangling for pointer-sized pointer unions.
In the future, with sufficiently advanced const generics, it might be possible to avoid this.
Methods
impl<A, B> UnionBuilder<Union2<A, B>>
[src]
pub const unsafe fn new() -> Self
[src]
Assert that creating pointer unions of these two types is safe.
Safety
Both A
and B
pointer types must be erasable,
and their erased form must align to at least u16
(#[repr(align(2))]
).
Examples
Sound:
UnionBuilder::<Union2<Box<u16>, &u32>>::new();
Unsound:
UnionBuilder::<Union2<Box<u16>, &u8>>::new();
impl<A, B, C, D> UnionBuilder<Union4<A, B, C, D>>
[src]
pub const unsafe fn new() -> Self
[src]
Assert that creating pointer unions of these four types is safe.
Safety
The A
, B
, C
, and D
pointer types must be erasable,
and their erased form must align to at least u32
(#[repr(align(4))]
).
Examples
Sound:
UnionBuilder::<Union4<Box<u32>, &u32, Arc<u32>, Arc<u64>>>::new();
Unsound:
UnionBuilder::<Union4<Box<u16>, &u16, Arc<u16>, Arc<u64>>>::new();
impl<A: ErasablePtr, B: ErasablePtr> UnionBuilder<Union2<A, B>>
[src]
pub fn a(self, a: A) -> Union2<A, B>
[src]
Construct a union at this variant.
pub fn b(self, b: B) -> Union2<A, B>
[src]
Construct a union at this variant.
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr> UnionBuilder<Union4<A, B, C, D>>
[src]
pub fn a(self, a: A) -> Union4<A, B, C, D>
[src]
Construct a union at this variant.
pub fn b(self, b: B) -> Union4<A, B, C, D>
[src]
Construct a union at this variant.
pub fn c(self, c: C) -> Union4<A, B, C, D>
[src]
Construct a union at this variant.
pub fn d(self, d: D) -> Union4<A, B, C, D>
[src]
Construct a union at this variant.
Trait Implementations
impl<U> Clone for UnionBuilder<U>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<U> Copy for UnionBuilder<U>
[src]
impl<U> Debug for UnionBuilder<U>
[src]
Auto Trait Implementations
impl<U> Send for UnionBuilder<U> where
U: Send,
U: Send,
impl<U> Sync for UnionBuilder<U> where
U: Sync,
U: Sync,
impl<U> Unpin for UnionBuilder<U> where
U: Unpin,
U: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erasable for T
[src]
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
[src]
const ACK_1_1_0: bool
[src]
fn erase(this: NonNull<Self>) -> NonNull<Erased>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,