Skip to content

hof: No explanation how to create a function that takes a closure #406

Closed
@kornelski

Description

@kornelski

The example uses preexisting functions accepting closures, but doesn't show how to create one.

I'm struggling with this, because the compiler won't infer the closure type, and closure types were not explained (related #405).

fn callme<T>(callable: T) {
    callable(12i32);
}

fn main() {
    callme(|&:arg| -arg);
}

error: expected function, found T

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions