@@ 52,18 52,19 @@ impl Config {
let config: Config = toml::from_str(&config_str)?;
Ok(config)
}
+
+ fn read() -> Result<String, io::Error> {
+ use std::fs::File;
+ use std::io::prelude::*;
+
+ let cfg_path = Config::locate()?;
+ let mut file = File::open(cfg_path)?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents)?;
+ Ok(contents)
+ }
}
-fn read_config() -> Result<String, io::Error> {
- use std::fs::File;
- use std::io::prelude::*;
-
- let cfg_path = Config::locate()?;
- let mut file = File::open(cfg_path)?;
- let mut contents = String::new();
- file.read_to_string(&mut contents)?;
- Ok(contents)
-}
fn open_url(url: &str, config: Config) {
@@ 101,7 102,7 @@ fn main() {
}
let url = &args[1];
- let config_str = read_config().expect("Unable to read configuration file");
+ let config_str = Config::read().expect("Unable to read configuration file");
let config = Config::parse(&config_str).expect("Unable to parse configuration");
open_url(url, config);
}