rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
675 stars 147 forks source link

Unable to determine the length of an array of registers #776

Closed jessebraham closed 7 months ago

jessebraham commented 7 months ago

After updating to the most recent version and regenerating our PACs, there is (seemingly) no longer a way of determining how many registers have been collected into an array.

Previously we were able to do something like:

self.aes.text.len()

However, as far as I can tell, this is no longer possible. I would expect there to either be a method returning the length of the array, or an associated constant. This information is all available in the SVD, so it seems strange to not be able to access it via the PAC.

burrbull commented 7 months ago

As now we have iterators you could use reg_iter().count() instead. For sequential registers it will be optimized to slice::len. Although not sure about non-sequential ones.

jessebraham commented 7 months ago

Ahh of course, sorry I had forgotten about that. Thanks for the tip.