| Crates.io | fn_box |
| lib.rs | fn_box |
| version | 1.0.5 |
| created_at | 2014-12-22 11:40:30.261253+00 |
| updated_at | 2015-12-11 23:58:51.47213+00 |
| description | Box up your FnOnces |
| homepage | |
| repository | https://github.com/nathan7/fn_box |
| max_upload_size | |
| id | 623 |
| size | 2,536 |
Box up your FnOnces!
trait FnBox<Args, Result = ()> {
extern "rust-call" fn call_box(self: Box<Self>, args: Args) -> Result;
}
impl<F, Args, Result> FnBox<Args, Result> for F where F: FnOnce<Args, Result> { … }
#[cfg(not(when_coherence_is_fixed))]
impl<'a> FnOnce() for Box<FnBox() + 'a> { … }
#[cfg(when_coherence_is_fixed)]
impl<'a, Args, Result> FnOnce<Args, Result> for Box<FnBox<Args, Result> + 'a> { … }
let hello: Box<FnBox()> = Box::new(move || { println!("hello world!") });
hello();
let plus_one: Box<FnBox(_) -> _> = Box::new(move |x: i32| { x + 1 });
assert_eq!(plus_one.call_box((3,)), 4);