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

Partially revert #283 #286

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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]

- Partially revert #283

## [v0.14.10] - 2025-02-08

- Do not derive `DimElement`
Expand Down
23 changes: 17 additions & 6 deletions svd-rs/src/derive_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,25 @@ impl DeriveFrom for FieldInfo {

impl<T> DeriveFrom for MaybeArray<T>
where
T: DeriveFrom,
T: DeriveFrom + crate::Name,
{
fn derive_from(&self, other: &Self) -> Self {
use std::ops::Deref;
let info = self.deref().derive_from(other.deref());
match self {
Self::Single(_) => Self::Single(info),
Self::Array(_, dim) => Self::Array(info, dim.clone()),
match (self, other) {
(Self::Single(info), Self::Single(other_info)) => {
Self::Single(info.derive_from(other_info))
}
(Self::Single(info), Self::Array(other_info, other_dim)) => {
if info.name().contains("%s") {
let mut dim = other_dim.clone();
dim.dim_name = None;
Self::Array(info.derive_from(other_info), dim)
} else {
Self::Single(info.derive_from(other_info))
}
}
(Self::Array(info, dim), Self::Single(other_info) | Self::Array(other_info, _)) => {
Self::Array(info.derive_from(other_info), dim.clone())
}
}
}
}