Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code shared from the Rust Playground
trait Kind<T> {
type Make;
enum OptionKind {}
impl<T> Kind<T> for OptionKind {
type Make = Option<T>;
trait FunctorKind<A, B>: Kind<A> + Kind<B> {
fn fmapk(<Self as Kind<A>>::Make, impl Fn(A) -> B) -> <Self as Kind<B>>::Make;
impl<A, B> FunctorKind<A, B> for OptionKind {
fn fmapk(me: Option<A>, f: impl Fn(A) -> B) -> Option<B> {
match me {
Some(m) => Some(f(m)),
None => None,
fn main() {
println!("{:?}", OptionKind::fmapk(Some(10), |a| a + 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.