mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 01:25:54 +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);
|
|
}
|