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§
Sourcefn call(i: Input) -> Self::Output
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.
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.