rust/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
570 B
Rust
Raw Normal View History

2023-01-25 19:18:01 +00:00
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
}