Trait frunk::traits::Func

source ·
pub trait Func<Input> {
    type Output;

    // Required method
    fn call(i: Input) -> Self::Output;
}
Expand description

This is a simple, user-implementable alternative to Fn.

Might not be necessary if/when Fn(Once, Mut) traits are implementable in stable Rust

Required Associated Types§

Required Methods§

source

fn call(i: Input) -> Self::Output

Call the Func.

Notice that this does not take a self argument, which in turn means Func cannot effectively close over a context. This decision trades power for convenience; a three-trait Fn heirarchy like that in std provides a great deal of power in a small fraction of use-cases, but it also comes at great expanse to the other 95% of use cases.

Object Safety§

This trait is not object safe.

Implementors§