Commit Graph

22 Commits

Author SHA1 Message Date
Taylor Cramer
3005bf360d Pin stabilization: fix doctests 2018-12-21 20:42:50 -08:00
Taylor Cramer
610bcaf6f3 Stabilize Pin 2018-12-21 20:42:50 -08:00
Taylor Cramer
20d694a95f Update Pin API to match the one proposed for stabilization
Remove pin::Unpin reexport and add Unpin to the prelude.
Change Pin associated functions to methods.
Rename get_mut_unchecked_ to get_unchecked_mut
Remove impl Unpin for Pin
Mark Pin repr(transparent)
2018-12-21 20:41:24 -08:00
Michael Hewson
153f5a7892 Stabilize Rc, Arc and Pin as method receivers
This lets you write methods using `self: Rc<Self>`, `self: Arc<Self>`, `self: Pin<&mut Self>`, `self: Pin<Box<Self>`, and other combinations involving `Pin` and another stdlib receiver type, without needing the `arbitrary_self_types`. Other user-created receiver types can be used, but they still require the feature flag to use.

This is implemented by introducing a new trait, `Receiver`, which the method receiver's type must implement if the `arbitrary_self_types` feature is not enabled. To keep composed receiver types such as `&Arc<Self>` unstable, the receiver type is also required to implement `Deref<Target=Self>` when the feature flag is not enabled.

This lets you use `self: Rc<Self>` and `self: Arc<Self>` in stable Rust, which was not allowed previously. It was agreed that they would be stabilized in #55786. `self: Pin<&Self>` and other pinned receiver types do not require the `arbitrary_self_types` feature, but they cannot be used on stable because `Pin` still requires the `pin` feature.
2018-12-20 01:14:01 -05:00
Taylor Cramer
709b7515e7 Rename Pinned marker type to PhantomPinned 2018-12-12 12:23:58 -08:00
Taylor Cramer
94856a7553 Expand documantation for std::pin module 2018-12-12 12:23:17 -08:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Daniel Alley
38d2f9b470 Fix docstring spelling mistakes 2018-11-09 23:14:46 -05:00
Michael Hewson
f12c250e40 Replace CoerceSized trait with DispatchFromDyn
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {}
```

instead of

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {}
```

this way the trait is really just a subset of `CoerceUnsized`.

The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too.

I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.
2018-11-01 18:16:59 -04:00
Michael Hewson
192900e7c2 Add CoerceSized impls throughout libstd
This will make receiver types like `Rc<Self>` and `Pin<&mut Self>`
object-safe.
2018-11-01 18:16:22 -04:00
Matthias Krüger
4972beaf65 fix typos in various places 2018-10-23 15:56:25 +02:00
Alexander Ronald Altman
bb0abe98a7
Remove useless lifetimes from Pin impls. 2018-09-26 16:03:05 -05:00
Taylor Cramer
574bca7262 Cleanup Deref impls and add ?Sized bound to &mut T impls 2018-09-18 15:42:51 -07:00
Taylor Cramer
3ec1810e32 Cleanup and fix method resolution issue 2018-09-17 16:31:33 -07:00
Without Boats
974bdc80fe
Update to a new pinning API. 2018-09-01 06:57:58 +02:00
Niv Kaminer
83ca347343 remove copyright headers now that they are not madatory 2018-08-25 00:07:00 +03:00
Niv Kaminer
b26cce5ec0 link to items in pin module to std docs 2018-08-23 10:16:58 +03:00
Niv Kaminer
871e89b351 capitalize and punctuate libcore pin module 2018-08-23 02:13:01 +03:00
Niv Kaminer
1c26be3929 fix broken link to Unpin due to reexport 2018-08-23 02:13:01 +03:00
Niv Kaminer
2f501a1bc4 fix PinMut documentation 2018-08-23 01:37:03 +03:00
Niv Kaminer
30bb4af5d8 add top-level documentation to the std pin module 2018-08-23 01:37:03 +03:00
Niv Kaminer
13da951868 move PinMut into pin module and export through std 2018-08-23 01:37:03 +03:00