]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/overloaded-calls-simple.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![feature(lang_items, unboxed_closures, fn_traits)]
14 use std
::ops
::{Fn, FnMut, FnOnce}
;
21 impl FnMut
<(i32,)> for S1
{
22 extern "rust-call" fn call_mut(&mut self, (z
,): (i32,)) -> i32 {
27 impl FnOnce
<(i32,)> for S1
{
29 extern "rust-call" fn call_once(mut self, args
: (i32,)) -> i32 {
39 impl Fn
<(i32,)> for S2
{
40 extern "rust-call" fn call(&self, (z
,): (i32,)) -> i32 {
45 impl FnMut
<(i32,)> for S2
{
46 extern "rust-call" fn call_mut(&mut self, args
: (i32,)) -> i32 { self.call(args) }
49 impl FnOnce
<(i32,)> for S2
{
51 extern "rust-call" fn call_once(self, args
: (i32,)) -> i32 { self.call(args) }
59 impl FnOnce
<(i32,i32)> for S3
{
61 extern "rust-call" fn call_once(self, (z
,zz
): (i32,i32)) -> i32 {
62 self.x
* self.y
* z
* zz
78 let ans
= s
.call((3,));