Skip to content

Commit 3930839

Browse files
authored
Merge pull request #224 from jannic-dev-forks/interpolate-none-path
Let opt_interpolate return the plain string if path is None
2 parents 118cc58 + 518d0df commit 3930839

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG-rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This changelog tracks the Rust `svdtools` project. See
55

66
## [Unreleased]
77

8+
* If there is no path to interpolate, show unmodified `description`.
9+
810
## [v0.3.13] 2024-03-29
911

1012
* Interpolate path and name in `description` and `derivedFrom`

src/patch/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,11 @@ impl Spec for str {
804804
}
805805

806806
fn opt_interpolate<T: Interpolate>(path: &Option<&T>, s: Option<&str>) -> Option<String> {
807-
path.and_then(|path| path.interpolate_opt(s))
807+
if let Some(path) = path {
808+
path.interpolate_opt(s)
809+
} else {
810+
s.map(ToString::to_string)
811+
}
808812
}
809813

810814
trait Interpolate {

0 commit comments

Comments
 (0)