Update
This commit is contained in:
parent
44ea23c1b5
commit
34f8dbffab
8 changed files with 78 additions and 50 deletions
|
|
@ -7,17 +7,17 @@ use std::path::Path;
|
|||
use resources::Resource;
|
||||
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
|
||||
|
||||
pub struct Dir<D> where D: AsRef<str> + fmt::Display {
|
||||
pub struct Dir<D> where D: AsRef<str> {
|
||||
path: D
|
||||
}
|
||||
|
||||
impl<D> Dir<D> where D: AsRef<str> + fmt::Display {
|
||||
impl<D> Dir<D> where D: AsRef<str> {
|
||||
pub fn new(path: D) -> Self {
|
||||
Dir { path: path }
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> Symbol for Dir<D> where D: AsRef<str> + fmt::Display {
|
||||
impl<D> Symbol for Dir<D> where D: AsRef<str> {
|
||||
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
let metadata = fs::metadata(self.path.as_ref());
|
||||
// Check if dir exists
|
||||
|
|
@ -48,7 +48,7 @@ impl<D> Symbol for Dir<D> where D: AsRef<str> + fmt::Display {
|
|||
}
|
||||
|
||||
fn provides(&self) -> Option<Vec<Resource>> {
|
||||
Some(vec![ Resource::new("dir", self.path.to_string()) ])
|
||||
Some(vec![ Resource::new("dir", self.path.as_ref()) ])
|
||||
}
|
||||
|
||||
fn as_action<'a>(&'a self, runner: &'a SymbolRunner) -> Box<Action + 'a> {
|
||||
|
|
@ -60,8 +60,8 @@ impl<D> Symbol for Dir<D> where D: AsRef<str> + fmt::Display {
|
|||
}
|
||||
}
|
||||
|
||||
impl<D> fmt::Display for Dir<D> where D: AsRef<str> + fmt::Display {
|
||||
impl<D> fmt::Display for Dir<D> where D: AsRef<str> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error>{
|
||||
write!(f, "Dir {}", self.path)
|
||||
write!(f, "Dir {}", self.path.as_ref())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue