diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-25 11:00:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-25 11:00:13 +0100 |
| commit | e3fbaa87c970f12620631edfbfa1bb3c05b34633 (patch) | |
| tree | 78e9cdd60ffdc01228067a9666fd3ab661ef0b4e | |
| parent | fbb81fa89cf5c78d73244e6db3ac5e041d3c33ca (diff) | |
| parent | fb65ca14b21cb3210251915864007d7c0d64ae21 (diff) | |
| download | rust-e3fbaa87c970f12620631edfbfa1bb3c05b34633.tar.gz rust-e3fbaa87c970f12620631edfbfa1bb3c05b34633.zip | |
Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhpratt
Clarify transmute example The example claims using an iterator will copy the entire vector, but this is not true in practice thanks to internal specializations in the stdlib (see https://godbolt.org/z/cnxo3MYs5 for confirmation that this doesn't reallocate nor iterate over the vec's elements). Since neither the copy nor the optimization is guaranteed I opted for saying that they _may_ happen.
| -rw-r--r-- | library/core/src/intrinsics.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index dec31548fc8..bb1debfc77d 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1356,7 +1356,7 @@ extern "rust-intrinsic" { /// let v_clone = v_orig.clone(); /// /// // This is the suggested, safe way. - /// // It does copy the entire vector, though, into a new array. + /// // It may copy the entire vector into a new one though, but also may not. /// let v_collected = v_clone.into_iter() /// .map(Some) /// .collect::<Vec<Option<&i32>>>(); |
