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

Skip to content
Commit 5cbc0aee authored by Martin Geisler's avatar Martin Geisler Committed by Cherrypicker Worker
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
(cherry picked from https://android-review.googlesource.com/q/commit:88f250890e0f62b471470758cc3e5bc71ff1728e)
Merged-In: I84a780d703079940642664e462deadd8ed335ec6
Change-Id: I84a780d703079940642664e462deadd8ed335ec6
parent ff269cb5
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