Skip to content

Commit f05e7a4

Browse files
committed
Use fs::read_to_string
1 parent fe743d0 commit f05e7a4

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/lib.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ at your option.
5858

5959
use std::{
6060
collections::btree_map::{self, BTreeMap},
61-
env, fmt,
62-
fs::{self, File},
63-
io::{self, Read},
61+
env, fmt, fs, io,
6462
path::{Path, PathBuf},
6563
sync::Mutex,
6664
time::SystemTime,
@@ -216,17 +214,10 @@ fn sanitize_crate_name<S: AsRef<str>>(name: S) -> String {
216214

217215
/// Open the given `Cargo.toml` and parse it into a hashmap.
218216
fn open_cargo_toml(path: &Path) -> Result<Table, Error> {
219-
let mut content = String::new();
220-
File::open(path)
221-
.map_err(|e| Error::CouldNotRead {
222-
source: e,
223-
path: path.into(),
224-
})?
225-
.read_to_string(&mut content)
226-
.map_err(|e| Error::CouldNotRead {
227-
source: e,
228-
path: path.into(),
229-
})?;
217+
let content = fs::read_to_string(path).map_err(|e| Error::CouldNotRead {
218+
source: e,
219+
path: path.into(),
220+
})?;
230221
toml::from_str(&content).map_err(|e| Error::InvalidToml { source: e })
231222
}
232223

0 commit comments

Comments
 (0)