Skip to content

Functions provided in a vector to a vec::each can't be called #3550

@AngryLawyer

Description

@AngryLawyer

This may turn out to me being a plonker, but while maintaining rust-sdl to match the latest version of Master, I had to swap out vec::iter for vec::each, as the former has vanished.

I have code similar to this:

fn first() {
    io::println("LOL FIRST");
}

fn second() {
    io::println("LOL SECOND");
}

fn main() {
    let functions = [
        first,
        second
    ];

    for functions.each |func| { func(); };
}

And I'm getting this in response.

first_class_test.rs:15:32: 15:39 error: mismatched types: expected function or foreign function but found &fn()
first_class_test.rs:15     for functions.each |func| { func(); };
                                                       ^~~~~~~

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions