EFanZh · GitHub

Feature gate: #![feature(vec_from_fn)]

This is a tracking issue for the Vec::from_fn method.

Public API

impl<T> Vec<T> {
    pub fn from_fn<F>(length: usize, f: F) -> Self
    where
        F: FnMut(usize) -> T,
    {
        (0..length).map(f).collect()
    }
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Read the original on github.com ↗