Skip to content

Commit

Permalink
format module
Browse files Browse the repository at this point in the history
  • Loading branch information
vitiral committed Mar 22, 2018
1 parent f388c69 commit dcd6606
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
6 changes: 2 additions & 4 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ impl PathDir {
}
}


#[inline(always)]
/// Do the conversion _without checking_.
///
Expand Down Expand Up @@ -296,14 +295,13 @@ impl PathDir {
/// # Ok(()) } fn main() { try_main().unwrap() }
/// ```
pub fn symlink<P: AsRef<Path>>(&self, dst: P) -> Result<()> {
symlink_dir(&self, &dst)
.map_err(|err| {
symlink_dir(&self, &dst).map_err(|err| {
Error::new(
err,
&format!("linking to {} from", dst.as_ref().display()),
self.clone().into(),
)
})
})
}

/// Return a reference to a basic `std::path::Path`
Expand Down
7 changes: 3 additions & 4 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,13 @@ impl PathFile {
/// # Ok(()) } fn main() { try_main().unwrap() }
/// ```
pub fn symlink<P: AsRef<Path>>(&self, dst: P) -> Result<()> {
symlink_file(&self, &dst)
.map_err(|err| {
symlink_file(&self, &dst).map_err(|err| {
Error::new(
err,
&format!("linking to {} from", dst.as_ref().display()),
self.clone().into(),
)
})
})
}

/// Remove (delete) the file from the filesystem, consuming self.
Expand Down Expand Up @@ -572,5 +571,5 @@ fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()

#[cfg(windows)]
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
:: std::os::windows::fs::symlink_file(src, dst)
::std::os::windows::fs::symlink_file(src, dst)
}
21 changes: 12 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,18 @@ mod tests {

use super::*;

macro_rules! assert_match { ($re: expr, $err: expr) => {{
let re = Regex::new(&$re).unwrap();
let err = $err.to_string();
assert!(
re.is_match(&err), "\nGot Err : {:?}\nMatching against: {:?}",
err.to_string(),
$re
);
}}}
macro_rules! assert_match {
($re: expr, $err: expr) => {{
let re = Regex::new(&$re).unwrap();
let err = $err.to_string();
assert!(
re.is_match(&err),
"\nGot Err : {:?}\nMatching against: {:?}",
err.to_string(),
$re
);
}};
}

fn escape<P: AsRef<Path>>(path: P) -> String {
regex::escape(&format!("{}", path.as_ref().display()))
Expand Down
8 changes: 5 additions & 3 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ use std::os::windows::ffi::{OsStrExt, OsStringExt};

use super::{PathAbs, PathArc, PathDir, PathFile};

macro_rules! map_err { ($res: expr) => {{
$res.map_err(|err| serde::de::Error::custom(&err.to_string()))
}}}
macro_rules! map_err {
($res: expr) => {{
$res.map_err(|err| serde::de::Error::custom(&err.to_string()))
}};
}

impl PathArc {
/// Convert the `PathArc` into an STFU8 `String`.
Expand Down

0 comments on commit dcd6606

Please sign in to comment.