Skip to content

Problem with generics and bare functions #1038

Closed
@brson

Description

@brson
fn main() {
    fn# foo<T>() { }

    // This wants to build a closure over type int,
    // but there's no way to do that while still being a bare function
    let f: fn#() = foo::<int>;
}

As a result we can't do bare-fn spawn for generic functions, which is pretty important:

#[test]
fn spawn_polymorphic() {
    fn# foo<~T>(x: T) { log_err x; }

    task::spawn2(true, foo);
    task::spawn2(42, foo);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions