2017-12-10 23:29:24 +03:00
|
|
|
struct Example {
|
2019-05-28 14:46:13 -04:00
|
|
|
example: Box<dyn Fn(i32) -> i32>
|
2016-04-03 22:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let demo = Example {
|
|
|
|
|
example: Box::new(|x| {
|
|
|
|
|
x + 1
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-24 23:40:24 -07:00
|
|
|
demo.example(1);
|
|
|
|
|
//~^ ERROR no method named `example`
|
2016-04-03 22:58:44 +02:00
|
|
|
// (demo.example)(1);
|
|
|
|
|
}
|