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.
This commit is contained in:
Matthias Krüger 2024-03-25 11:00:13 +01:00 committed by GitHub
commit e3fbaa87c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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>>>();