evobench_tools/utillib/
into_arc_path.rs

1use std::{
2    ffi::{OsStr, OsString},
3    path::{Path, PathBuf},
4    sync::Arc,
5};
6
7pub trait IntoArcPath {
8    fn into_arc_path(self) -> Arc<Path>;
9}
10
11impl IntoArcPath for PathBuf {
12    fn into_arc_path(self) -> Arc<Path> {
13        self.into()
14    }
15}
16
17impl IntoArcPath for &Path {
18    fn into_arc_path(self) -> Arc<Path> {
19        self.into()
20    }
21}
22
23impl IntoArcPath for String {
24    fn into_arc_path(self) -> Arc<Path> {
25        PathBuf::from(self).into()
26    }
27}
28
29impl IntoArcPath for &str {
30    fn into_arc_path(self) -> Arc<Path> {
31        Arc::<Path>::from(self.as_ref())
32    }
33}
34
35impl IntoArcPath for OsString {
36    fn into_arc_path(self) -> Arc<Path> {
37        PathBuf::from(self).into()
38    }
39}
40
41impl IntoArcPath for &OsStr {
42    fn into_arc_path(self) -> Arc<Path> {
43        Arc::<Path>::from(self.as_ref())
44    }
45}
46
47// CString has no direct conversion to PathBuf, and this module should
48// probably not offer one due to portability questions.