Support closures as array initializer
Open
Nobody has claimed this yet.
T-lang
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Currently the way to initialize an array is a bit unwieldy:
use std::mem;
#[derive(Debug)]
struct Codebook<T> {
x: T,
y: T
}
fn fill_thing_array(a : &mut [[Codebook<u8>; 4]; 4]) {
for (i, line) in a.iter_mut().enumerate() {
for (j, el) in line.iter_mut().enumerate() {
*el = Codebook { x: i as u8, y: j as u8};
}
}
}
...
let mut a = unsafe { mem::uninitialized() };
fill_thing_array(&mut a);
}
Would be nicer to provide a syntax to have something along the lines of
let a = [[|x, y| [Codebook {x: i as u8, y: j as u8}]; 4]; 4];
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's current and proposed Rust snippets, then research existing array-initialization and closure syntax to define the intended semantics. No files or tests are named; done would require a settled, reviewed design for closure-based array initialization and the corresponding RFC decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100