-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #119127 - joboet:array_repeat, r=scottmcm
Implement `array::repeat` See rust-lang/libs-team#310. I've decided to make the function use the input value as last element instead of cloning it to every position and dropping it, and to make this part of the API so that callers are not surprised by this behaviour. TODO: open a tracking issue. I'll wait for the ACP to be accepted, first. `@rustbot` label +T-libs-api +T-libs r? libs
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
#![feature(array_repeat)] | ||
|
||
use std::array::repeat; | ||
|
||
// CHECK-LABEL: @byte_repeat | ||
#[no_mangle] | ||
fn byte_repeat(b: u8) -> [u8; 1024] { | ||
// CHECK-NOT: alloca | ||
// CHECK-NOT: store | ||
// CHECK: memset | ||
repeat(b) | ||
} |