pub struct TypedVTableDirectBuilder<T> { /* private fields */ }Expand description
Type-safe builder for VTableDirect.
Generic over T at the type level, ensuring all function pointers
are for the same type. The transmute to erased pointers happens
inside the builder methods.
Implementations§
Source§impl<T> TypedVTableDirectBuilder<T>
impl<T> TypedVTableDirectBuilder<T>
Sourcepub const fn display(self, f: fn(&T, &mut Formatter<'_>) -> Result) -> Self
pub const fn display(self, f: fn(&T, &mut Formatter<'_>) -> Result) -> Self
Set the display function.
Sourcepub const fn debug(self, f: fn(&T, &mut Formatter<'_>) -> Result) -> Self
pub const fn debug(self, f: fn(&T, &mut Formatter<'_>) -> Result) -> Self
Set the debug function.
Sourcepub const fn hash(self, f: fn(&T, &mut HashProxy<'static>)) -> Self
pub const fn hash(self, f: fn(&T, &mut HashProxy<'static>)) -> Self
Set the hash function.
Pass <T as Hash>::hash::<HashProxy> to use the type’s Hash impl.
Sourcepub const fn invariants(self, f: fn(&T) -> Result<(), String>) -> Self
pub const fn invariants(self, f: fn(&T) -> Result<(), String>) -> Self
Set the invariants function.
Sourcepub const fn parse(
self,
f: unsafe fn(&str, *mut T) -> Result<(), ParseError>,
) -> Self
pub const fn parse( self, f: unsafe fn(&str, *mut T) -> Result<(), ParseError>, ) -> Self
Set the parse function.
Sourcepub const fn try_from(
self,
f: unsafe fn(*mut T, &'static Shape, PtrConst) -> Result<(), String>,
) -> Self
pub const fn try_from( self, f: unsafe fn(*mut T, &'static Shape, PtrConst) -> Result<(), String>, ) -> Self
Set the try_from function. Arguments: (dst, src_shape, src_ptr)
Sourcepub const fn try_into_inner(
self,
f: unsafe fn(*mut T) -> Result<PtrMut, String>,
) -> Self
pub const fn try_into_inner( self, f: unsafe fn(*mut T) -> Result<PtrMut, String>, ) -> Self
Set the try_into_inner function.
For transparent types, this extracts the inner value (consuming). Takes a pointer to the wrapper type, returns a pointer to the inner value.
Sourcepub const fn try_borrow_inner(
self,
f: unsafe fn(*const T) -> Result<PtrMut, String>,
) -> Self
pub const fn try_borrow_inner( self, f: unsafe fn(*const T) -> Result<PtrMut, String>, ) -> Self
Set the try_borrow_inner function.
For transparent types, this borrows the inner value. Takes a pointer to the wrapper type, returns a pointer to the inner value.
Sourcepub const fn partial_cmp(self, f: fn(&T, &T) -> Option<Ordering>) -> Self
pub const fn partial_cmp(self, f: fn(&T, &T) -> Option<Ordering>) -> Self
Set the partial_cmp function.
Sourcepub const fn build(self) -> VTableDirect
pub const fn build(self) -> VTableDirect
Build the VTable.