Skip to content

Tracking Issue for core::array::(try_)repeat(_with) (feature array_repeat) #91613

Closed
@scottmcm

Description

@scottmcm

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.

Public API

// 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

Unresolved Questions

  • repeat_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions