Skip to content

Commit

Permalink
Use fs::read_to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Jan 23, 2023
1 parent fe743d0 commit f05e7a4
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ at your option.

use std::{
collections::btree_map::{self, BTreeMap},
env, fmt,
fs::{self, File},
io::{self, Read},
env, fmt, fs, io,
path::{Path, PathBuf},
sync::Mutex,
time::SystemTime,
Expand Down Expand Up @@ -216,17 +214,10 @@ fn sanitize_crate_name<S: AsRef<str>>(name: S) -> String {

/// Open the given `Cargo.toml` and parse it into a hashmap.
fn open_cargo_toml(path: &Path) -> Result<Table, Error> {
let mut content = String::new();
File::open(path)
.map_err(|e| Error::CouldNotRead {
source: e,
path: path.into(),
})?
.read_to_string(&mut content)
.map_err(|e| Error::CouldNotRead {
source: e,
path: path.into(),
})?;
let content = fs::read_to_string(path).map_err(|e| Error::CouldNotRead {
source: e,
path: path.into(),
})?;
toml::from_str(&content).map_err(|e| Error::InvalidToml { source: e })
}

Expand Down

0 comments on commit f05e7a4

Please sign in to comment.