@@ -761,85 +761,6 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
761
761
}
762
762
}
763
763
764
- /// `FnBox` is deprecated and will be removed.
765
- /// `Box<dyn FnOnce()>` can be called directly, since Rust 1.35.0.
766
- ///
767
- /// `FnBox` is a version of the `FnOnce` intended for use with boxed
768
- /// closure objects. The idea was that where one would normally store a
769
- /// `Box<dyn FnOnce()>` in a data structure, you whould use
770
- /// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
771
- /// that a `FnBox` closure can only be called if it is boxed.
772
- ///
773
- /// # Examples
774
- ///
775
- /// Here is a snippet of code which creates a hashmap full of boxed
776
- /// once closures and then removes them one by one, calling each
777
- /// closure as it is removed. Note that the type of the closures
778
- /// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce()
779
- /// -> i32>`.
780
- ///
781
- /// ```
782
- /// #![feature(fnbox)]
783
- /// #![allow(deprecated)]
784
- ///
785
- /// use std::boxed::FnBox;
786
- /// use std::collections::HashMap;
787
- ///
788
- /// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> {
789
- /// let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new();
790
- /// map.insert(1, Box::new(|| 22));
791
- /// map.insert(2, Box::new(|| 44));
792
- /// map
793
- /// }
794
- ///
795
- /// fn main() {
796
- /// let mut map = make_map();
797
- /// for i in &[1, 2] {
798
- /// let f = map.remove(&i).unwrap();
799
- /// assert_eq!(f(), i * 22);
800
- /// }
801
- /// }
802
- /// ```
803
- ///
804
- /// In Rust 1.35.0 or later, use `FnOnce`, `FnMut`, or `Fn` instead:
805
- ///
806
- /// ```
807
- /// use std::collections::HashMap;
808
- ///
809
- /// fn make_map() -> HashMap<i32, Box<dyn FnOnce() -> i32>> {
810
- /// let mut map: HashMap<i32, Box<dyn FnOnce() -> i32>> = HashMap::new();
811
- /// map.insert(1, Box::new(|| 22));
812
- /// map.insert(2, Box::new(|| 44));
813
- /// map
814
- /// }
815
- ///
816
- /// fn main() {
817
- /// let mut map = make_map();
818
- /// for i in &[1, 2] {
819
- /// let f = map.remove(&i).unwrap();
820
- /// assert_eq!(f(), i * 22);
821
- /// }
822
- /// }
823
- /// ```
824
- #[ rustc_paren_sugar]
825
- #[ unstable( feature = "fnbox" , issue = "28796" ) ]
826
- #[ rustc_deprecated( reason = "use `FnOnce`, `FnMut`, or `Fn` instead" , since = "1.37.0" ) ]
827
- pub trait FnBox < A > : FnOnce < A > {
828
- /// Performs the call operation.
829
- fn call_box ( self : Box < Self > , args : A ) -> Self :: Output ;
830
- }
831
-
832
- #[ unstable( feature = "fnbox" , issue = "28796" ) ]
833
- #[ rustc_deprecated( reason = "use `FnOnce`, `FnMut`, or `Fn` instead" , since = "1.37.0" ) ]
834
- #[ allow( deprecated, deprecated_in_future) ]
835
- impl < A , F > FnBox < A > for F
836
- where F : FnOnce < A >
837
- {
838
- fn call_box ( self : Box < F > , args : A ) -> F :: Output {
839
- self . call_once ( args)
840
- }
841
- }
842
-
843
764
#[ unstable( feature = "coerce_unsized" , issue = "27732" ) ]
844
765
impl < T : ?Sized + Unsize < U > , U : ?Sized > CoerceUnsized < Box < U > > for Box < T > { }
845
766
0 commit comments