Improve code clarity, write Alert::load()

This commit is contained in:
paoda 2020-05-24 05:06:33 -05:00
parent 16e3f73616
commit bc9080fe2f
1 changed files with 10 additions and 6 deletions

View File

@ -15,8 +15,8 @@ pub mod pomodoro {
device: &'a Device,
}
impl Alert<'_> {
pub fn new<'a, P: AsRef<Path>>(path: &'a P, device: &'a Device) -> Alert<'a> {
impl<'a> Alert<'a> {
pub fn new<P: AsRef<Path>>(path: &'a P, device: &'a Device) -> Alert<'a> {
Alert {
path: path.as_ref(),
device,
@ -30,8 +30,12 @@ pub mod pomodoro {
rodio::play_raw(self.device, source.convert_samples());
}
}
}
pub fn load<P: AsRef<Path>>(mut self, new_path: &'a P) -> Self {
self.path = new_path.as_ref();
self
}
}
#[derive(Copy, Clone, Debug)]
pub enum State {
Work,
@ -75,13 +79,13 @@ pub mod pomodoro {
}
pub fn with_data_directory<P: AsRef<Path>>(mut self, path: &P) -> Config {
self.data_directory = path.as_ref().to_owned();
self.data_directory = path.as_ref().to_path_buf();
self
}
fn get_data_directory() -> PathBuf {
let dirs = ProjectDirs::from("moe", "paoda", "domasi").unwrap();
dirs.data_dir().to_owned()
let dirs = ProjectDirs::from("moe", "paoda", "Domasi").unwrap();
dirs.data_dir().to_path_buf()
}
}