2015-01-08 04:54:35 -06:00
|
|
|
fn a<F:Fn(isize, isize) -> isize>(mut f: F) {
|
2014-07-30 00:08:39 -05:00
|
|
|
let g = &mut f;
|
|
|
|
f(1, 2); //~ ERROR cannot borrow `f` as immutable
|
2018-11-05 07:32:00 -06:00
|
|
|
use_mut(g);
|
2014-07-30 00:08:39 -05:00
|
|
|
}
|
2015-01-08 04:54:35 -06:00
|
|
|
fn b<F:FnMut(isize, isize) -> isize>(f: F) {
|
2019-04-22 02:40:08 -05:00
|
|
|
f(1, 2); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable
|
2014-07-30 00:08:39 -05:00
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
|
2014-07-30 00:08:39 -05:00
|
|
|
f(1, 2);
|
|
|
|
f(1, 2); //~ ERROR use of moved value
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|
2018-11-05 07:32:00 -06:00
|
|
|
|
|
|
|
fn use_mut<T>(_: &mut T) { }
|