replace f.call_mut(a, b, ..) with f(a, b, ..)

This commit is contained in:
Jorge Aparicio 2015-01-05 14:07:10 -05:00
parent c98814b124
commit ec11f66dbf
17 changed files with 28 additions and 28 deletions

View File

@ -29,7 +29,7 @@ fn innocent_looking_victim() {
} 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);
},

View File

@ -14,6 +14,6 @@ use std::ops::FnMut;
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);
}

View File

@ -13,7 +13,7 @@
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() {

View File

@ -18,7 +18,7 @@
*/
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 {

View File

@ -20,8 +20,8 @@ impl<'a, I, O: 'a> Parser<'a, I, O> {
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)
}
}

View File

@ -27,7 +27,7 @@ fn tester()
};
let path = path::Path::new("blah");
assert!(loader.call_mut((&path,)).is_ok());
assert!(loader(&path).is_ok());
}
pub fn main() {}

View File

@ -50,7 +50,7 @@ fn main() {
x: 3,
y: 3,
};
let ans = s.call_mut((3,));
let ans = s(3);
assert_eq!(ans, 27);
let s = S2 {
@ -64,7 +64,7 @@ fn main() {
x: 3,
y: 3,
};
let ans = s.call_once((3, 1));
let ans = s(3, 1);
assert_eq!(ans, 27);
}

View File

@ -42,19 +42,19 @@ struct Goldfyshe {
}
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 }
}

View File

@ -19,7 +19,7 @@ use std::ops::FnMut;
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);
}

View File

@ -18,15 +18,15 @@ use std::ops::{Fn,FnMut,FnOnce};
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() {

View File

@ -25,15 +25,15 @@ impl Fn<(int,),int> for S {
}
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() {

View File

@ -25,11 +25,11 @@ impl FnMut<(int,),int> for S {
}
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() {

View File

@ -13,7 +13,7 @@
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() {

View File

@ -22,11 +22,11 @@ impl FnMut<(int,),int> for S {
}
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() {

View File

@ -17,12 +17,12 @@ 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)
}

View File

@ -14,6 +14,6 @@ use std::ops::FnMut;
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);
}

View File

@ -12,6 +12,6 @@
fn main() {
let onetime = |: x| x;
onetime.call_once((0i,));
onetime(0i);
}