blob: 3bf6b7bb9b19e484ea0de703d880777df2316433 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
pub struct Trader<'a> {
closure: Box<dyn Fn(&mut Trader) + 'a>,
}
impl<'a> Trader<'a> {
pub fn new() -> Self {
Trader {
closure: Box::new(|_| {}),
}
}
pub fn set_closure(&mut self, function: impl Fn(&mut Trader) + 'a) {
//foo
}
}
fn main() {
let closure = |trader : Trader| {
println!("Woooosh!");
};
let mut trader = Trader::new();
trader.set_closure(closure);
//~^ ERROR type mismatch in closure arguments
}
|