Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(fn_traits, unboxed_closures)]
- #[allow(non_camel_case_types)]
- struct get_max;
- fn get_max_fn_body<T: PartialOrd>(a: T, b: T) -> T {
- if a > b { a } else { b }
- }
- impl FnOnce<(i32, i32)> for get_max {
- type Output = i32;
- #[inline(always)]
- extern "rust-call" fn call_once(self, args: (i32, i32)) -> Self::Output {
- get_max_fn_body.call_once(args)
- }
- }
- impl FnMut<(i32, i32)> for get_max {
- #[inline(always)]
- extern "rust-call" fn call_mut(&mut self, args: (i32, i32)) -> Self::Output {
- get_max_fn_body.call_once(args)
- }
- }
- fn main() {
- let x = get_max.call_mut(1,2);
- println!("x: {}", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement