Skip to content

Commit 3ad33ff

Browse files
Stop open-coding read_to_string
1 parent 9df8ebb commit 3ad33ff

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/symbolize/gimli/parse_running_mmaps_unix.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// in `mod libs_dl_iterate_phdr` (e.g. linux, freebsd, ...); it may be more
33
// general purpose, but it hasn't been tested elsewhere.
44

5-
use super::mystd::fs::File;
5+
use super::mystd::fs::{self, File};
66
use super::mystd::io::Read;
77
use super::mystd::str::FromStr;
88
use super::{OsString, String, Vec};
@@ -54,18 +54,9 @@ pub(super) struct MapsEntry {
5454
}
5555

5656
pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, &'static str> {
57-
let mut v = Vec::new();
58-
let mut proc_self_maps =
59-
File::open("/proc/self/maps").map_err(|_| "Couldn't open /proc/self/maps")?;
60-
let mut buf = String::new();
61-
let _bytes_read = proc_self_maps
62-
.read_to_string(&mut buf)
63-
.map_err(|_| "Couldn't read /proc/self/maps")?;
64-
for line in buf.lines() {
65-
v.push(line.parse()?);
66-
}
57+
let buf = fs::read_to_string("/proc/self/maps").map_err(|_| "")?;
6758

68-
Ok(v)
59+
buf.lines().map(|line| line.parse()).collect()
6960
}
7061

7162
impl MapsEntry {

0 commit comments

Comments
 (0)