Trait Param

Source
pub trait Param<T> {
    // Required method
    fn param(&self) -> T;
}
Expand description

Item of type T has been set in a certain_map slot.

When used as a trait bound, Param<T> ensures that the constrained type has previously used the ParamSet<T> trait to set the value of type T in a certain_map slot. This allows the caller to guarantee at compile-time that the value of T is available and can be retrieved from the implementing type using the param method.

By using the Param<T> trait bound, you can enforce that the necessary value has been set before attempting to retrieve it, preventing runtime errors caused by missing or uninitialized values.

§Example

fn process_param<P: Param<T>, T>(param_provider: P) {
    let value: T = param_provider.param();
    // Use the value of type T
}

Required Methods§

Source

fn param(&self) -> T

Implementors§

Source§

impl<T> Param<T> for T
where T: Clone,