3 f2: extern "C" fn(data: u8),
4 f3: unsafe fn(data: u8),
7 struct FuncContainerOuter {
8 container: Box<FuncContainer>
11 struct Obj<F> where F: FnOnce() -> u32 {
17 boxed_closure: Box<dyn FnOnce() -> u32>,
20 struct Wrapper<F> where F: FnMut() -> u32 {
28 fn check_expression() -> Obj<Box<dyn FnOnce() -> u32>> {
29 Obj { closure: Box::new(|| 42_u32) as Box<dyn FnOnce() -> u32>, not_closure: 42 }
33 // test variations of function
35 let o_closure = Obj { closure: || 42, not_closure: 42 };
36 o_closure.closure(); //~ ERROR no method named `closure` found
38 o_closure.not_closure();
39 //~^ ERROR no method named `not_closure` found
41 let o_func = Obj { closure: func, not_closure: 5 };
42 o_func.closure(); //~ ERROR no method named `closure` found
44 let boxed_fn = BoxedObj { boxed_closure: Box::new(func) };
45 boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
47 let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<dyn FnOnce() -> u32> };
48 boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
50 // test expression writing in the notes
52 let w = Wrapper { wrap: o_func };
53 w.wrap.closure();//~ ERROR no method named `closure` found
56 //~^ ERROR no method named `not_closure` found
58 check_expression().closure();//~ ERROR no method named `closure` found
61 impl FuncContainerOuter {
64 (*self.container).f1(1); //~ ERROR no method named `f1` found
65 (*self.container).f2(1); //~ ERROR no method named `f2` found
66 (*self.container).f3(1); //~ ERROR no method named `f3` found