Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk

Prefer to use repeat_n over repeat().take()

More from https://github.com/rust-lang/rust/pull/147464, but batch processed with `ast-grep` to find and replace.

second commit add notes for library: affaf532f9

r? ``@RalfJung``
This commit is contained in:
Stuart Cook
2025-10-09 18:43:26 +11:00
committed by GitHub
16 changed files with 37 additions and 37 deletions

View File

@@ -110,7 +110,7 @@ pub fn get_span_and_frames<'tcx>(
if frame.times < 3 {
let times = frame.times;
frame.times = 0;
frames.extend(std::iter::repeat(frame).take(times as usize));
frames.extend(std::iter::repeat_n(frame, times as usize));
} else {
frames.push(frame);
}

View File

@@ -59,7 +59,7 @@ fn check_validity_requirement_strict<'tcx>(
if kind == ValidityRequirement::Zero {
cx.write_bytes_ptr(
allocated.ptr(),
std::iter::repeat(0_u8).take(ty.layout.size().bytes_usize()),
std::iter::repeat_n(0_u8, ty.layout.size().bytes_usize()),
)
.expect("failed to write bytes for zero valid check");
}