Skip to content

Instantly share code, notes, and snippets.

@anka-213
Forked from anonymous/playground.rs
Created September 27, 2016 20:57
Show Gist options
  • Save anka-213/7cca739c95a0942ed448931f6e5406dc to your computer and use it in GitHub Desktop.
Save anka-213/7cca739c95a0942ed448931f6e5406dc to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#[derive(Clone)]
struct Foo (i32);
type Bar = i32;
impl Foo {
fn go(&self, _: &i32) { }
}
fn _ice() {
let a = vec![].into_iter();
let _ = a.map(Foo(1).clone());
}
impl FnOnce<(Bar,)> for Foo {
type Output = ();
extern "rust-call" fn call_once(self, (args,): (Bar,)) -> Self::Output {
self.go(&args)
}
}
impl FnMut<(Bar,)> for Foo {
extern "rust-call" fn call_mut(&mut self, (args,): (Bar,)) -> Self::Output {
self.go(&args)
}
}
impl FnOnce<Bar> for Foo {
type Output = ();
extern "rust-call" fn call_once(self, args: Bar) -> Self::Output {
self.go(&args)
}
}
impl FnMut<Bar> for Foo {
extern "rust-call" fn call_mut(&mut self, args: Bar) -> Self::Output {
self.go(&args)
}
}
fn main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment