Feature gate: #![feature(array_repeat)]
This is a tracking issue for creating a fixed-size array by repeatedly Cloning
an item, or by repeatedly calling a possibly-fallible nullary FnMut
.
// core::array pub fn repeat<T: Clone, const N: usize>(value: T) -> [T; N]; pub fn repeat_with<T, const N: usize>(f: impl FnMut() -> T) -> [T; N]; pub fn try_repeat_with<R: Try, const N: usize>( f: impl FnMut() -> R, ) -> ChangeOutputType<R, [R::Output; N]> where R::Residual: Residual<[R::Output; N]>;Steps / History
resize(_with)
and (try_)repeat(_with)
for arrays #91506repeat_with
and try_repeat_with
are very similar to from_fn
and try_from_fn
( Tracking issue for try_array_from_fn
#89379), just that they take nullary instead of unary functions. Anyone considering stabilizing these should think about those, and vice versa.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4