Skip to content

Commit ebc0e62

Browse files
committed
Partially revert #283
1 parent 4075e69 commit ebc0e62

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

svd-rs/src/derive_from.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,20 @@ where
112112
T: DeriveFrom,
113113
{
114114
fn derive_from(&self, other: &Self) -> Self {
115-
use std::ops::Deref;
116-
let info = self.deref().derive_from(other.deref());
117-
match self {
118-
Self::Single(_) => Self::Single(info),
119-
Self::Array(_, dim) => Self::Array(info, dim.clone()),
115+
match (self, other) {
116+
(Self::Single(info), Self::Single(other_info)) => info.derive_from(other_info).single(),
117+
(Self::Single(info), Self::Array(other_info, other_dim)) => {
118+
if info.contains("%s") {
119+
let mut dim = other_dim.clone();
120+
dim.dim_name = None;
121+
info.derive_from(other_info).array(dim)
122+
} else {
123+
info.derive_from(other_info).single()
124+
}
125+
}
126+
(Self::Array(info, dim), Self::Single(other_info) | Self::Array(other_info, _)) => {
127+
info.derive_from(other_info).array(dim.clone())
128+
}
120129
}
121130
}
122131
}

0 commit comments

Comments
 (0)