Skip to content

Commit

Permalink
Merge pull request #286 from rust-embedded/derive-revert
Browse files Browse the repository at this point in the history
Partially revert #283
  • Loading branch information
burrbull authored Feb 10, 2025
2 parents 4075e69 + bb0bd88 commit 129cb42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
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())
}
}
}
}

0 comments on commit 129cb42

Please sign in to comment.