Skip to content

Not all function items implement Fn* traits #1968

@xmh0511

Description

@xmh0511

https://doc.rust-lang.org/reference/types/function-item.html#r-type.fn-item.traits says:

All function items implement Fn, FnMut, FnOnce, Copy, Clone, Send, and Sync.

Consider this example:

fn check<F: Fn()>(_: F) {}
extern "C" fn foo() {}
fn main() {
    check(foo);
}

The compiler reports an error:

the trait `Fn()` is not implemented for fn item `extern "C" fn() {foo}`

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