diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-27 23:01:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-27 23:01:00 +0200 |
| commit | 2f6cf36b326d5045872785782cdd0c121a3198ec (patch) | |
| tree | 40fe74655b94ca276ddeda29a233ec47281bec44 /src/liballoc | |
| parent | 7ddfae74b1e22b4de71f0fe839577b985c545a64 (diff) | |
| parent | a99a7b7f35e3b30862058cc28ed4b0cf51638cf4 (diff) | |
| download | rust-2f6cf36b326d5045872785782cdd0c121a3198ec.tar.gz rust-2f6cf36b326d5045872785782cdd0c121a3198ec.zip | |
Rollup merge of #62043 - Centril:remove-fnbox, r=cramertj
Remove `FnBox` Remove `FnBox` since we now have `Box<dyn FnOnce>`. Closes https://github.com/rust-lang/rust/issues/28796. r? @cramertj
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 76b660fba68..9109a730cce 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -761,85 +761,6 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> { } } -/// `FnBox` is deprecated and will be removed. -/// `Box<dyn FnOnce()>` can be called directly, since Rust 1.35.0. -/// -/// `FnBox` is a version of the `FnOnce` intended for use with boxed -/// closure objects. The idea was that where one would normally store a -/// `Box<dyn FnOnce()>` in a data structure, you whould use -/// `Box<dyn FnBox()>`. The two traits behave essentially the same, except -/// that a `FnBox` closure can only be called if it is boxed. -/// -/// # Examples -/// -/// Here is a snippet of code which creates a hashmap full of boxed -/// once closures and then removes them one by one, calling each -/// closure as it is removed. Note that the type of the closures -/// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce() -/// -> i32>`. -/// -/// ``` -/// #![feature(fnbox)] -/// #![allow(deprecated)] -/// -/// use std::boxed::FnBox; -/// use std::collections::HashMap; -/// -/// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> { -/// let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new(); -/// map.insert(1, Box::new(|| 22)); -/// map.insert(2, Box::new(|| 44)); -/// map -/// } -/// -/// fn main() { -/// let mut map = make_map(); -/// for i in &[1, 2] { -/// let f = map.remove(&i).unwrap(); -/// assert_eq!(f(), i * 22); -/// } -/// } -/// ``` -/// -/// In Rust 1.35.0 or later, use `FnOnce`, `FnMut`, or `Fn` instead: -/// -/// ``` -/// use std::collections::HashMap; -/// -/// fn make_map() -> HashMap<i32, Box<dyn FnOnce() -> i32>> { -/// let mut map: HashMap<i32, Box<dyn FnOnce() -> i32>> = HashMap::new(); -/// map.insert(1, Box::new(|| 22)); -/// map.insert(2, Box::new(|| 44)); -/// map -/// } -/// -/// fn main() { -/// let mut map = make_map(); -/// for i in &[1, 2] { -/// let f = map.remove(&i).unwrap(); -/// assert_eq!(f(), i * 22); -/// } -/// } -/// ``` -#[rustc_paren_sugar] -#[unstable(feature = "fnbox", issue = "28796")] -#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")] -pub trait FnBox<A>: FnOnce<A> { - /// Performs the call operation. - fn call_box(self: Box<Self>, args: A) -> Self::Output; -} - -#[unstable(feature = "fnbox", issue = "28796")] -#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")] -#[allow(deprecated, deprecated_in_future)] -impl<A, F> FnBox<A> for F - where F: FnOnce<A> -{ - fn call_box(self: Box<F>, args: A) -> F::Output { - self.call_once(args) - } -} - #[unstable(feature = "coerce_unsized", issue = "27732")] impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {} |
