Skip to content

Commit 3a61258

Browse files
authored
Merge pull request #533 from workingjubilee/use-std-fn-from-1.55
2 parents 6f3ab0b + 9668103 commit 3a61258

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

src/symbolize/gimli/parse_running_mmaps_unix.rs

+8-18
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,10 @@ impl FromStr for MapsEntry {
9797
let pathname_str = parts.next().unwrap_or(""); // pathname may be omitted.
9898

9999
let hex = |s| usize::from_str_radix(s, 16).map_err(|_| "Couldn't parse hex number");
100-
let address = {
101-
// This could use `range_str.split_once('-')` once the MSRV passes 1.52.
102-
if let Some(idx) = range_str.find('-') {
103-
let (start, rest) = range_str.split_at(idx);
104-
let (_div, limit) = rest.split_at(1);
105-
(hex(start)?, hex(limit)?)
106-
} else {
107-
return Err("Couldn't parse address range");
108-
}
100+
let address = if let Some((start, limit)) = range_str.split_once('-') {
101+
(hex(start)?, hex(limit)?)
102+
} else {
103+
return Err("Couldn't parse address range");
109104
};
110105
let perms: [char; 4] = {
111106
let mut chars = perms_str.chars();
@@ -117,15 +112,10 @@ impl FromStr for MapsEntry {
117112
perms
118113
};
119114
let offset = hex(offset_str)?;
120-
let dev = {
121-
// This could use `dev_str.split_once(':')` once the MSRV passes 1.52.
122-
if let Some(idx) = dev_str.find(':') {
123-
let (major, rest) = dev_str.split_at(idx);
124-
let (_div, minor) = rest.split_at(1);
125-
(hex(major)?, hex(minor)?)
126-
} else {
127-
return Err("Couldn't parse dev")?;
128-
}
115+
let dev = if let Some((major, minor)) = dev_str.split_once(':') {
116+
(hex(major)?, hex(minor)?)
117+
} else {
118+
return Err("Couldn't parse dev");
129119
};
130120
let inode = hex(inode_str)?;
131121
let pathname = pathname_str.into();

tests/current-exe-mismatch.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,8 @@ fn find_interpreter(me: &Path) -> Result<PathBuf, EarlyExit> {
118118
let line = line?;
119119
let line = line.trim();
120120
let prefix = "[Requesting program interpreter: ";
121-
// This could use `line.split_once` and `suffix.rsplit_once` once the MSRV passes 1.52
122-
if let Some(idx) = line.find(prefix) {
123-
let (_, suffix) = line.split_at(idx + prefix.len());
124-
if let Some(idx) = suffix.rfind("]") {
125-
let (found_path, _ignore_remainder) = suffix.split_at(idx);
121+
if let Some((_, suffix)) = line.split_once(prefix) {
122+
if let Some((found_path, _)) = suffix.rsplit_once("]") {
126123
return Ok(found_path.into());
127124
}
128125
}

0 commit comments

Comments
 (0)