rust/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.rs
2023-01-25 19:26:53 +00:00

29 lines
570 B
Rust

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
}