Skip to content

Commit e3fbaa8

Browse files
authored
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.
2 parents fbb81fa + fb65ca1 commit e3fbaa8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ extern "rust-intrinsic" {
13561356
/// let v_clone = v_orig.clone();
13571357
///
13581358
/// // This is the suggested, safe way.
1359-
/// // It does copy the entire vector, though, into a new array.
1359+
/// // It may copy the entire vector into a new one though, but also may not.
13601360
/// let v_collected = v_clone.into_iter()
13611361
/// .map(Some)
13621362
/// .collect::<Vec<Option<&i32>>>();

0 commit comments

Comments
 (0)