refactor(config): Simplify

This commit is contained in:
Ed Page 2021-03-01 12:19:56 -06:00
parent 60dbf0a254
commit b5827004a2

View file

@ -1,5 +1,4 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::io::Read;
pub trait ConfigSource { pub trait ConfigSource {
fn walk(&self) -> Option<&dyn WalkSource> { fn walk(&self) -> Option<&dyn WalkSource> {
@ -107,9 +106,7 @@ pub struct Config {
impl Config { impl Config {
pub fn from_file(path: &std::path::Path) -> Result<Self, anyhow::Error> { pub fn from_file(path: &std::path::Path) -> Result<Self, anyhow::Error> {
let mut file = std::fs::File::open(path)?; let s = std::fs::read_to_string(path)?;
let mut s = String::new();
file.read_to_string(&mut s)?;
Self::from_toml(&s) Self::from_toml(&s)
} }