pub fn repeat<T: Clone, const N: usize>(val: T) -> [T; N]🔬This is a nightly-only experimental API. (
array_repeat #126695)Expand description
Creates an array of type [T; N] by repeatedly cloning a value.
This is the same as [val; N], but it also works for types that do not
implement Copy.
The provided value will be used as an element of the resulting array and will be cloned N - 1 times to fill up the rest. If N is zero, the value will be dropped.
§Example
Creating muliple copies of a String: