1 #![feature(fn_traits, unboxed_closures)]
3 use std::ops::{Fn, FnMut, FnOnce};
10 impl Fn<(isize,)> for SFn {
11 extern "rust-call" fn call(&self, (z,): (isize,)) -> isize {
16 impl FnMut<(isize,)> for SFn {
17 extern "rust-call" fn call_mut(&mut self, args: (isize,)) -> isize { self.call(args) }
20 impl FnOnce<(isize,)> for SFn {
22 extern "rust-call" fn call_once(self, args: (isize,)) -> isize { self.call(args) }
30 impl FnMut<(isize,)> for SFnMut {
31 extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize {
36 impl FnOnce<(isize,)> for SFnMut {
38 extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) }
45 impl FnOnce<(String,)> for SFnOnce {
48 extern "rust-call" fn call_once(self, (z,): (String,)) -> usize {
49 self.x.len() + z.len()
59 s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
67 s(3); //~ ERROR cannot borrow `s` as mutable, as it is not declared as mutable
72 x: "hello".to_string(),
74 s(" world".to_string());
75 s(" world".to_string()); //~ ERROR use of moved value: `s`
80 fn use_mut<T>(_: &mut T) { }