【发布时间】:2021-09-05 01:31:10
【问题描述】:
struct User {
id: i8,
name: &'static str
}
struct UserMethods {
add_user: Fn(User) -> (),
}
fn main() {
UserMethods {
add_user: |user| {
}
};
}
编译器说,
error[E0277]: the size for values of type `(dyn Fn(User) + 'static)` cannot be known at compilation time
--> src/main.rs:11:5
|
11 | / UserMethods {
12 | | add_user: |user| {},
13 | | };
| |_____^ doesn't have a size known at compile-time
【问题讨论】: