comparison rust/hg-core/src/utils/hg_path.rs @ 45544:2d5dfc8fed55

hg-core: impl TryFrom<PathBuff> for HgPathBuf Differential Revision: https://phab.mercurial-scm.org/D9048
author Antoine Cezar <antoine.cezar@octobus.net>
date Tue, 15 Sep 2020 10:52:28 +0200
parents 26114bd6ec60
children 2e2033081274
comparison
equal deleted inserted replaced
45543:2f8227a12592 45544:2d5dfc8fed55
4 // 4 //
5 // This software may be used and distributed according to the terms of the 5 // This software may be used and distributed according to the terms of the
6 // GNU General Public License version 2 or any later version. 6 // GNU General Public License version 2 or any later version.
7 7
8 use std::borrow::Borrow; 8 use std::borrow::Borrow;
9 use std::convert::TryFrom;
9 use std::ffi::{OsStr, OsString}; 10 use std::ffi::{OsStr, OsString};
10 use std::fmt; 11 use std::fmt;
11 use std::ops::Deref; 12 use std::ops::Deref;
12 use std::path::{Path, PathBuf}; 13 use std::path::{Path, PathBuf};
13 14
513 514
514 buf.check_state()?; 515 buf.check_state()?;
515 Ok(buf) 516 Ok(buf)
516 } 517 }
517 518
519 impl TryFrom<PathBuf> for HgPathBuf {
520 type Error = HgPathError;
521 fn try_from(path: PathBuf) -> Result<Self, Self::Error> {
522 path_to_hg_path_buf(path)
523 }
524 }
525
518 #[cfg(test)] 526 #[cfg(test)]
519 mod tests { 527 mod tests {
520 use super::*; 528 use super::*;
521 use pretty_assertions::assert_eq; 529 use pretty_assertions::assert_eq;
522 530