Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 88f25089 authored by Martin Geisler's avatar Martin Geisler
Browse files

pdl: Avoid unwrap when parsing arrays

Because https://doc.rust-lang.org/std/array/fn.try_from_fn.html is not
yet stable, we do this by collecting the intermediate values into a
Vec, which we turn into an array.

Alternatives would be to emit an array literal (can be a lot more
code), use MaybeUninit (unsafe, can leak memory) or to let all structs
and enums implement Default (extra code, need to pick a default for
enums).

The generated test files now have 94 explicit unwraps. They are all
due to the API and the way it emulates inheritance and OOP.

Tag: #feature
Bug: 279758009
Test: atest pdl_tests pdl_rust_generator_tests_{le,be} pdl_generated_files_compile
Change-Id: I84a780d703079940642664e462deadd8ed335ec6
parent 311a6872
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment