Events2Join

Making a const version of Rust's array::from_fn


Making a const version of Rust's array::from_fn - How hard can it be?

The main appeal of a const array::from_fn would be ergonomics (no need to write the loop each time), although that would indeed be addressed by a macro.

Making a const version of Rust's array::from_fn - How hard can it be?

In this post, I will focus on std::array::from_fn, a function that is unfortunately not const. After explaining why I'd find it useful in const contexts, I'll ...

Making a const version of Rust's array::from_fn - How hard can it be?

I'm sure the author already knows this, but you could accomplish the stated goal for the SIMD swizzle use case with a const fn :

Making a const version of Rust's array::from_fn - How hard can it be ...

TLDRA blog post explores the process of making a const version of Rust's array::from_fn function and the challenges it presents. It discusses the usefulness ...

Const context: Create array with const generic length from init function

... version: play.rust-lang.org/… – eggyal. Commented Aug 28, 2023 at ... core::array::from_fn (not even an RFC for its const ness exists yet) ...

rust - How to initialize a const generic array? - Stack Overflow

Here are some ways to construct an array of arbitrary length. You can use std::array::from_fn which will allow constructing an array of any ...

Make `std::array::from_fn` a `const fn` - rust-lang/libs-team - GitHub

Title says it all. Making std::array::from_fn a const fn would allow the simplified versions to just be used for initializing static variables.

from_fn in std::array - Rust

Function from_fn. Copy item path. Settings · Help. Summary 1.63.0 · source. pub fn from_fn

Build array from part of another array - help - Rust Users Forum

Looks easier but i'm surprised of rust cant to create array with copy of another without "try... ... ::array::from_fn(|i| ar1[i]);. https://play.

Rust Weekly : "Making a const version of Rust…" - Mastodon

Making a const version of Rust's array::from_fn - How hard can it be? https://gendignoux.com/blog/2024/06/17/const-array-from-fn.html Discussions: ...

from_fn in core::array - Rust - kernel

Copy item path. 1.63.0 · source · [−]. pub fn from_fn ... creating array of 5 elements. let array = core::array::from_fn(|i| i); ...

Making a const version of Rust's array::from_fn - How hard can it be ...

Rsync25 stacked 20 sats posting https://gendignoux.com/blog/2024/06/17/const-array-from-fn.html.

Suggest const block, instead of const item, for array repeat ... - GitHub

Rust Version. rustc 1.81.0-nightly (bcf94dec5 2024-06-23) binary: rustc ... Should I make the array::from_fn suggestion machine-applicable too and ...

Methods for Array Initialization in Rust (2018) | Hacker News

... Copy; only that the value is a constant: const EMPTY: String = String::new(); let a: [String; 1000] = [EMPTY; 1000]; const NONE: Option ...

6 months into Rust: what was good in 2017 and what will be better in ...

Making a const version of Rust's array::from_fn - How hard can it be? ... And 30 more posts on this blog! Previous Rust from a C++ and OCaml ...

Matrix in nalgebra::base - Rust - Docs.rs

Creating mutable matrix views from &mut [T] from_slice_mut , from_slice_with_strides_mut … Views based on index and length row , columns , view … Mutable views ...

rust - Rust programming | Lobsters

Making a const version of Rust's array::from_fn - How hard can it be? rust gendignoux.com · gendx avatar authored by gendx 4 months ago | caches. Archive.org ...

Simd in std::simd::prelude - Rust

... from_fn(|i| a[i] + b[i]); let prod = array::from_fn(|i| a[i] ... ::from_array and Simd::from_slice . ... pub const fn from_array(array: [T; N]) -> Simd

Constant fun (const fn) with Rust - Rainer Stropek - YouTube

Everybody knows constants from other programming languages. But as so often, Rust is different and knows a lot of tricks regarding constants ...

arraylib - Rust - Docs.rs

Because of lack of const generics it's impossible to implement traits on arrays ... array_init (analogs to Array::from_fn and Array::from_iter ); array_ext ...