#[repr(C)]pub struct EmptyStruct {
pub _reserved: u8,
}Expand description
FFI-safe void type to replace () in Result types.
Since () (unit type) has zero size, it’s not FFI-safe.
This type provides a minimal 1-byte representation that can be
safely passed across the C ABI boundary.
§Usage
Instead of Result<(), Error>, use Result<EmptyStruct, Error>.
§Example
ⓘ
fn do_something() -> Result<EmptyStruct, MyError> {
// ... do work ...
Ok(EmptyStruct::default())
}Fields§
§_reserved: u8Reserved byte to ensure the struct has non-zero size. Always initialized to 0.
Implementations§
Source§impl EmptyStruct
impl EmptyStruct
Trait Implementations§
Source§impl Clone for EmptyStruct
impl Clone for EmptyStruct
Source§fn clone(&self) -> EmptyStruct
fn clone(&self) -> EmptyStruct
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EmptyStruct
impl Debug for EmptyStruct
Source§impl Default for EmptyStruct
impl Default for EmptyStruct
Source§fn default() -> EmptyStruct
fn default() -> EmptyStruct
Returns the “default value” for a type. Read more
Source§impl From<()> for EmptyStruct
impl From<()> for EmptyStruct
Source§impl From<EmptyStruct> for ()
impl From<EmptyStruct> for ()
Source§fn from(_: EmptyStruct) -> Self
fn from(_: EmptyStruct) -> Self
Converts to this type from the input type.
Source§impl Hash for EmptyStruct
impl Hash for EmptyStruct
Source§impl Ord for EmptyStruct
impl Ord for EmptyStruct
Source§fn cmp(&self, other: &EmptyStruct) -> Ordering
fn cmp(&self, other: &EmptyStruct) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for EmptyStruct
impl PartialEq for EmptyStruct
Source§fn eq(&self, other: &EmptyStruct) -> bool
fn eq(&self, other: &EmptyStruct) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for EmptyStruct
impl PartialOrd for EmptyStruct
impl Copy for EmptyStruct
impl Eq for EmptyStruct
impl StructuralPartialEq for EmptyStruct
Auto Trait Implementations§
impl Freeze for EmptyStruct
impl RefUnwindSafe for EmptyStruct
impl Send for EmptyStruct
impl Sync for EmptyStruct
impl Unpin for EmptyStruct
impl UnsafeUnpin for EmptyStruct
impl UnwindSafe for EmptyStruct
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more