rust/library/alloc/src
Matthias Krüger 5b64aab2b6
Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc
Improve documentation for constructors of pinned `Box`es

Adds a cross-references between `Box::pin` and `Box::into_pin` (and other related methods, i.e. the equivalent `From` implementation, and the unstable `pin_in` method), in particular now that `into_pin` [was stabilized](https://github.com/rust-lang/rust/pull/97397). The main goal is to further improve visibility of the fact that `Box<T> -> Pin<Box<T>>` conversion exits in the first place, and that `Box::pin(x)` is – essentially – just a convenience function for `Box::into_pin(Box::new(x))`

The motivating context why I think this is important is even experienced Rust users overlooking the existence this kind of conversion, [e.g. in this thread on IRLO](https://internals.rust-lang.org/t/pre-rfc-function-variants/16732/7?u=steffahn); and also the fact that that discussion brought up that there would be a bunch of Box-construction methods "missing" such as e.g. methods with fallible allocation a la "`Box::try_pin`", and similar; while those are in fact *not* necessary, because you can use `Box::into_pin(Box::try_new(x)?)` instead.

I have *not* included explicit mention of methods (e.g. `try_new`) in the docs of stable methods (e.g. `into_pin`). (Referring to unstable API in stable API docs would be bad style IMO.) Stable examples I have in mind with the statement "constructing a (pinned) Box in a different way than with `Box::new`" are things like cloning a `Box`, or `Box::from_raw`. If/when `try_new` would get stabilized, it would become a very good concrete example use-case of `Box::into_pin` IMO.
2022-06-02 23:39:07 +02:00
..
alloc Use Box::new() instead of box syntax in alloc tests 2022-05-29 00:41:14 +02:00
boxed Add ThinBox type for 1 stack pointer sized heap allocated trait objects 2022-04-08 09:00:16 -07:00
collections Tweak insert docs 2022-05-31 22:08:14 -07:00
ffi Finish bumping stage0 2022-05-27 07:36:17 -04:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Use Box::new() instead of box syntax in alloc tests 2022-05-29 00:41:14 +02:00
sync Use Box::new() instead of box syntax in alloc tests 2022-05-29 00:41:14 +02:00
vec Auto merge of #97293 - est31:remove_box, r=oli-obk 2022-06-02 13:20:19 +00:00
alloc.rs Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu 2022-05-19 04:04:40 +00:00
borrow.rs Stabilize toowned_clone_into 2022-05-28 01:07:45 +09:00
boxed.rs Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc 2022-06-02 23:39:07 +02:00
fmt.rs remove useless cold 2022-05-29 20:40:56 +01:00
lib.rs Auto merge of #97293 - est31:remove_box, r=oli-obk 2022-06-02 13:20:19 +00:00
macros.rs Use #[rustc_box] in alloc instead of box syntax 2022-06-01 02:28:34 +02:00
raw_vec.rs Remove some unnecessary rustc_allow_const_fn_unstable attributes. 2022-05-13 16:01:18 +10:00
rc.rs Use Box::new() instead of box syntax in alloc tests 2022-05-29 00:41:14 +02:00
slice.rs Add reexport of slice::from{,_mut}_ptr_range to alloc & std 2022-05-30 15:44:56 +04:00
str.rs improve case conversion happy path 2022-05-26 13:18:57 +01:00
string.rs Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc 2022-05-21 01:56:51 +00:00
sync.rs Update sync.rs 2022-06-01 14:12:36 +02:00
task.rs Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
tests.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00