Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix indexes_as_range #241

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions svd-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Fix `indexes_as_range`

## [v0.14.3] - 2023-04-04

- Bump MSRV to 1.58.0
Expand Down
6 changes: 5 additions & 1 deletion svd-rs/src/dimelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ impl DimElement {
pub fn indexes_as_range(&self) -> Option<RangeInclusive<u32>> {
let mut integers = Vec::with_capacity(self.dim as usize);
for idx in self.indexes() {
integers.push(idx.parse::<u32>().ok()?);
let val = idx.parse::<u32>().ok()?;
if val.to_string() != idx {
return None;
}
Comment on lines +175 to +178
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does this fix?

that 01 != 1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to note, I think it's the wrong way to fix the issue but maybe it's not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does this fix?

that 01 != 1?

Yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment here to explain why we need the name to be an exact match with the integer representation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add comment yourself, please? I have issues with internet, maybe several days

integers.push(val);
}
let min = *integers.iter().min()?;
let max = *integers.iter().max()?;
Expand Down