pub struct Placeholder;Expand description
A zero-sized type used purely as a marker or placeholder when implementing Higher-Kinded Type (HKT) traits for concrete types.
This struct is essential for the “witness” pattern, where a concrete type
(like Option<T>) cannot directly implement an HKT trait due to Rust’s
type system limitations. Instead, a Witness type (e.g., OptionWitness)
implements the HKT trait, using Placeholder to represent the generic
parameters that are being abstracted over.
§Examples
use deep_causality_haft::{NoConstraint, HKT, Placeholder};
// A witness for Option<T>
pub struct OptionWitness;
impl HKT for OptionWitness {
type Constraint = NoConstraint;
type Type<T> = Option<T>;
}
let my_option: <OptionWitness as HKT>::Type<i32> = Some(10);
assert_eq!(my_option, Some(10));Auto Trait Implementations§
impl Freeze for Placeholder
impl RefUnwindSafe for Placeholder
impl Send for Placeholder
impl Sync for Placeholder
impl Unpin for Placeholder
impl UnsafeUnpin for Placeholder
impl UnwindSafe for Placeholder
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