#![cfg_attr(rustfmt, rustfmt::skip)] use ::safer_ffi::prelude::*; #[derive_ReprC(dyn)] trait FfiFnMut { fn call (&mut self) ; } impl FfiFnMut for T { fn call (&mut self) { self() } } #[ffi_export] fn call (mut f: VirtualPtr) { f.call(); f.call(); } #[derive_ReprC(dyn)] trait WithCallback { fn with(&self, scope: VirtualPtr) ; } #[derive_ReprC(dyn)] trait Example { fn method(&self); } fn _example<'r, T : 'r + Example> (owned: T, r: &'r T, m: &'r mut T) { let owned: VirtualPtr = Box::new(owned).into(); owned.method(); let r: VirtualPtr = r.into(); r.method(); let m: VirtualPtr = m.into(); m.method(); } #[derive_ReprC(dyn, Clone)] trait Cloneable { fn method(&self); } fn _cloneable<'r, T : 'r + Cloneable + Clone> (owned: T, r: &'r T) { let owned: VirtualPtr = Box::new(owned).into(); let owned2: VirtualPtr = owned.clone(); owned.method(); owned2.method(); let r: VirtualPtr = r.into(); let r2: VirtualPtr = r.clone(); r.method(); r2.method(); }