} else {
match x {
Some(ref msg) => {
- f.c.call_mut((f, true));
+ (f.c)(f, true);
//~^ ERROR: cannot borrow `*f` as mutable more than once at a time
println!("{}", msg);
},
pub fn main() {
let mut f = |&mut: x: int, y: int| -> int { x + y };
- let z = f.call_mut((1u, 2)); //~ ERROR type mismatch
+ let z = f(1u, 2); //~ ERROR type mismatch
println!("{}", z);
}
use std::ops::FnMut;
fn call_it<F:FnMut<(int,int),int>>(y: int, mut f: F) -> int {
- f.call_mut((2, y))
+ f(2, y)
}
pub fn main() {
*/
pub fn map(filename: String, mut emit: map_reduce::putter) {
- emit.call_mut((filename, "1".to_string(),));
+ emit(filename, "1".to_string());
}
mod map_reduce {
fn compose<K: 'a>(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> {
Parser {
parse: box move |&mut: x: I| {
- match (*self.parse).call_mut((x,)) {
- Ok(r) => (*rhs.parse).call_mut((r,)),
+ match (self.parse)(x) {
+ Ok(r) => (rhs.parse)(r),
Err(e) => Err(e)
}
}
};
let path = path::Path::new("blah");
- assert!(loader.call_mut((&path,)).is_ok());
+ assert!(loader(&path).is_ok());
}
pub fn main() {}
x: 3,
y: 3,
};
- let ans = s.call_mut((3,));
+ let ans = s(3);
assert_eq!(ans, 27);
let s = S2 {
x: 3,
y: 3,
};
- let ans = s.call_once((3, 1));
+ let ans = s(3, 1);
assert_eq!(ans, 27);
}
}
impl Pet for Catte {
- fn name(&self, mut blk: Box<FnMut(&str)>) { blk.call_mut((self.name.as_slice(),)) }
+ fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 4 }
fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 }
}
impl Pet for Dogge {
- fn name(&self, mut blk: Box<FnMut(&str)>) { blk.call_mut((self.name.as_slice(),)) }
+ fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 4 }
fn of_good_pedigree(&self) -> bool {
self.bark_decibels < 70 || self.tricks_known > 20
}
}
impl Pet for Goldfyshe {
- fn name(&self, mut blk: Box<FnMut(&str)>) { blk.call_mut((self.name.as_slice(),)) }
+ fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 0 }
fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
}
pub fn main() {
let mut adder = make_adder(3);
- let z = adder.call_mut((2,));
+ let z = adder(2);
println!("{}", z);
assert_eq!(z, 5);
}
fn square(x: int) -> int { x * x }
fn call_it<F:Fn(int)->int>(f: &F, x: int) -> int {
- f.call((x,))
+ f(x)
}
fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int {
- f.call_mut((x,))
+ f(x)
}
fn call_it_once<F:FnOnce(int)->int>(f: F, x: int) -> int {
- f.call_once((x,))
+ f(x)
}
fn main() {
}
fn call_it<F:Fn(int)->int>(f: &F, x: int) -> int {
- f.call((x,))
+ f(x)
}
fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int {
- f.call_mut((x,))
+ f(x)
}
fn call_it_once<F:FnOnce(int)->int>(f: F, x: int) -> int {
- f.call_once((x,))
+ f(x)
}
fn main() {
}
fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int {
- f.call_mut((x,))
+ f(x)
}
fn call_it_once<F:FnOnce(int)->int>(f: F, x: int) -> int {
- f.call_once((x,))
+ f(x)
}
fn main() {
use std::ops::FnMut;
fn call_it<F:FnMut<(int,int),int>>(y: int, mut f: F) -> int {
- f.call_mut((2, y))
+ f(2, y)
}
pub fn main() {
}
fn call_it<F:FnMut(int)->int>(mut f: F, x: int) -> int {
- f.call_mut((x,)) + 3
+ f(x) + 3
}
fn call_box(f: &mut FnMut(int) -> int, x: int) -> int {
- f.call_mut((x,)) + 3
+ f(x) + 3
}
fn main() {
task.call((0i, ));
let mut task: Box<FnMut(int) -> int> = box |&mut: x| x;
- task.call_mut((0i, ));
+ task(0i);
call(|:x| x, 22);
}
fn call<F:FnOnce(int) -> int>(f: F, x: int) -> int {
- f.call_once((x,))
+ f(x)
}
pub fn main() {
let mut f = |&mut: x: int, y: int| -> int { x + y };
- let z = f.call_mut((1, 2));
+ let z = f(1, 2);
assert_eq!(z, 3);
}
fn main() {
let onetime = |: x| x;
- onetime.call_once((0i,));
+ onetime(0i);
}