Repository navigation
Commit 6930ba5
Fix std::array default initializer generating empty Vec instead of sized Vec (#337)
`std::array<int, 3> v = {};` incorrectly generated `vec![]` (0 elements)
instead of a 3-element vector with default values.
```cpp
std::array<int, 3> v = {};
```
Before:
```rust
let mut v: Vec<i32> = vec![];
```
After:
```rust
let mut v: Vec<i32> = std::array::from_fn::<_, 3, _>(|_| Default::default()).to_vec();
```
- Fixes #313
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Nuno Lopes <nuno.lopes@tecnico.ulisboa.pt>1 parent 896e16e commit 6930ba5
4 files changed
Lines changed: 8 additions & 6 deletions
File tree
- cpp2rust/converter
- models
- tests/unit/out
- refcount
- unsafe
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3102 | 3102 | | |
3103 | 3103 | | |
3104 | 3104 | | |
3105 | | - | |
3106 | 3105 | | |
| 3106 | + | |
3107 | 3107 | | |
3108 | 3108 | | |
3109 | | - | |
| 3109 | + | |
3110 | 3110 | | |
3111 | 3111 | | |
3112 | 3112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1515 | 1515 | | |
1516 | 1516 | | |
1517 | 1517 | | |
1518 | | - | |
1519 | 1518 | | |
| 1519 | + | |
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
1523 | | - | |
| 1523 | + | |
1524 | 1524 | | |
1525 | 1525 | | |
1526 | 1526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
0 commit comments