mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
16 lines
253 B
Rust
16 lines
253 B
Rust
struct Example {
|
|
example: Box<dyn Fn(i32) -> i32>
|
|
}
|
|
|
|
fn main() {
|
|
let demo = Example {
|
|
example: Box::new(|x| {
|
|
x + 1
|
|
})
|
|
};
|
|
|
|
demo.example(1);
|
|
//~^ ERROR no method named `example`
|
|
// (demo.example)(1);
|
|
}
|