about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorCharles Lew <crlf0710@gmail.com>2019-02-11 11:09:26 +0900
committerCrLF0710 <crlf0710@gmail.com>2019-04-05 02:32:21 +0800
commitecc3e89dd072ed20d9aa6d53be0ab1c44d160232 (patch)
tree0cd68314a770eb4fdff72b596e0e0736d2ca97d7 /src/doc
parent45c0b28bcb6e383cd9d24d3845ee8accda31c889 (diff)
downloadrust-ecc3e89dd072ed20d9aa6d53be0ab1c44d160232.tar.gz
rust-ecc3e89dd072ed20d9aa6d53be0ab1c44d160232.zip
Stabilize boxed_closure_impls in 1.35.0.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/library-features/boxed-closure-impls.md98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/doc/unstable-book/src/library-features/boxed-closure-impls.md b/src/doc/unstable-book/src/library-features/boxed-closure-impls.md
deleted file mode 100644
index 5ceb54ff3b9..00000000000
--- a/src/doc/unstable-book/src/library-features/boxed-closure-impls.md
+++ /dev/null
@@ -1,98 +0,0 @@
-# `boxed_closure_impls`
-
-The tracking issue for this feature is [#48055]
-
-[#48055]: https://github.com/rust-lang/rust/issues/48055
-
-------------------------
-
-This includes the following blanket impls for closure traits:
-
-```rust,ignore
-impl<A, F: FnOnce<A> + ?Sized> FnOnce for Box<F> {
-    // ...
-}
-impl<A, F: FnMut<A> + ?Sized> FnMut for Box<F> {
-    // ...
-}
-impl<A, F: Fn<A> + ?Sized> Fn for Box<F> {
-    // ...
-}
-```
-
-## Usage
-
-`Box` can be used almost transparently. You can even use `Box<dyn FnOnce>` now.
-
-```rust
-#![feature(boxed_closure_impls)]
-
-fn main() {
-    let resource = "hello".to_owned();
-    // Create a boxed once-callable closure
-    let f: Box<dyn FnOnce(&i32)> = Box::new(|x| {
-        let s = resource;
-        println!("{}", x);
-        println!("{}", s);
-    });
-
-    // Call it
-    f(&42);
-}
-```
-
-## The reason for instability
-
-This is unstable because of the first impl.
-
-It would have been easy if we're allowed to tighten the bound:
-
-```rust,ignore
-impl<A, F: FnMut<A> + ?Sized> FnOnce for Box<F> {
-    // ...
-}
-```
-
-However, `Box<dyn FnOnce()>` drops out of the modified impl.
-To rescue this, we had had a temporary solution called [`fnbox`][fnbox].
-
-[fnbox]: library-features/fnbox.html
-
-Unfortunately, due to minor coherence reasons, `fnbox` and
-`FnOnce for Box<impl FnMut>` had not been able to coexist.
-We had preferred `fnbox` for the time being.
-
-Now, as [`unsized_locals`][unsized_locals] is implemented, we can just write the
-original impl:
-
-[unsized_locals]: language-features/unsized-locals.html
-
-```rust,ignore
-impl<A, F: FnOnce<A> + ?Sized> FnOnce for Box<F> {
-    type Output = <F as FnOnce<A>>::Output;
-
-    extern "rust-call" fn call_once(self, args: A) -> Self::Output {
-        // *self is an unsized rvalue
-        <F as FnOnce<A>>::call_once(*self, args)
-    }
-}
-```
-
-However, since `unsized_locals` is a very young feature, we're careful about
-this `FnOnce` impl now.
-
-There's another reason for instability: for compatibility with `fnbox`,
-we currently allow specialization of the `Box<impl FnOnce>` impl:
-
-```rust,ignore
-impl<A, F: FnOnce<A> + ?Sized> FnOnce for Box<F> {
-    type Output = <F as FnOnce<A>>::Output;
-
-    // we have "default" here
-    default extern "rust-call" fn call_once(self, args: A) -> Self::Output {
-        <F as FnOnce<A>>::call_once(*self, args)
-    }
-}
-```
-
-This isn't what we desire in the long term.