Skip to main content

Toggle

Trait Toggle 

Source
pub trait Toggle: Sized + Sealed {
    type Or<T: Toggle>: Toggle;
    type And<T: Toggle>: Toggle;

    // Required method
    fn try_create() -> Option<Self>;

    // Provided method
    fn create() -> Self { ... }
}
Expand description

A sealed trait for type-level booleans used to track pull capabilities.

Toggle is used to statically encode whether a pull can pend (CanPend) or end (CanEnd). This enables compile-time guarantees about pull behavior and allows the type system to optimize away impossible code paths.

Required Associated Types§

Source

type Or<T: Toggle>: Toggle

The result of OR-ing two toggles. Yes.or(T) = Yes, No.or(T) = T.

Source

type And<T: Toggle>: Toggle

The result of AND-ing two toggles. Yes.and(T) = T, No.and(T) = No.

Required Methods§

Source

fn try_create() -> Option<Self>

Attempts to create this type, returning Err(()) if Self is No.

Provided Methods§

Source

fn create() -> Self

Attempts to create this type, panicking if Self is No.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§