Skip to content

Commit 61ea71c

Browse files
vaindloewenheim
andauthored
Apply suggestions from code review
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
1 parent ad7b5ef commit 61ea71c

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

symbolic-debuginfo/src/sourcebundle.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,13 +1151,10 @@ mod tests {
11511151
.flat_map(|f| {
11521152
let path = f.abs_path_str();
11531153
session.source_by_path(&path).ok().flatten().map(|source| {
1154-
(
1155-
path,
1156-
match source {
1157-
SourceCode::Content(text) => text.into_owned(),
1158-
SourceCode::Url(_) => panic!(),
1159-
},
1160-
)
1154+
let SourceCode::Content(text) = source else {
1155+
unreachable!();
1156+
};
1157+
(path, text.into_owned())
11611158
})
11621159
})
11631160
.collect();

symbolic-ppdb/src/format/sourcelinks.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ impl SourceLinkMappings {
5353
*/
5454
let key = doc.0.to_lowercase();
5555
let url = doc.1.as_str().ok_or_else(Self::err)?.into();
56-
let pattern = if key.ends_with('*') {
57-
Pattern::Prefix(key[..(key.len() - 1)].into())
56+
let pattern = if let Some(prefix) = key.strip_suffix('*') {
57+
Pattern::Prefix(prefix.into())
5858
} else {
5959
Pattern::Exact(key)
6060
};
@@ -103,11 +103,8 @@ impl SourceLinkMappings {
103103
}
104104
}
105105
Pattern::Prefix(value) => {
106-
if path_lower.starts_with(value) {
107-
let replacement = path
108-
.get(value.len()..)
109-
.map(|v| v.replace('\\', "/"))
110-
.unwrap_or_default();
106+
if let Some(rest) = path_lower.strip_prefix(value) {
107+
let replacement = rest.replace('\\', "/");
111108
return Some(rule.url.replace('*', &replacement));
112109
}
113110
}

0 commit comments

Comments
 (0)