pub fn join<P1: AsRef<Utf8Path>, P2: AsRef<Utf8Path>>(a: P1, b: P2) -> Result<Utf8PathBuf> {
    let mut c = a.as_ref();
    if c.extension().is_some() {
        c = c
            .parent()
            .ok_or_else(|| Error::with_message(ErrorKind::Io, || "unable to get parent path of {c}"))?;
        // to directory
    }
    let mut c = PathBuf::from(c);
    let b = b.as_ref();
    c.append(b).with_context(ErrorKind::Io, || format!("append path {b} to {c:?}"))?;
    Utf8PathBuf::from_path_buf(c).map_err(|path| Error::with_message(ErrorKind::Io, || format!("converting path to UTF-8: {path:?}")))
}
/// Joins two files paths together
///
/// If the first path ends with a file name (i.e., the last component has a file extension),
/// the file component is dropped from that path.
Joins two files paths together
If the first path ends with a file name ,
the file component is dropped from that path.
Joins two files paths together If the first path ends with a file name the file component is dropped from that path .
pub fn join<P1: AsRef<Utf8Path>, P2: AsRef<Utf8Path>>(a: P1, b: P2) -> Result<Utf8PathBuf> {
    let mut c = a.as_ref();
    if c.extension().is_some() {
        c = c
            .parent()
            .ok_or_else(|| Error::with_message(ErrorKind::Io, || "unable to get parent path of {c}"))?;
        // to directory
    }
    let mut c = PathBuf::from(c);
    let b = b.as_ref();
    c.append(b).with_context(ErrorKind::Io, || format!("append path {b} to {c:?}"))?;
    Utf8PathBuf::from_path_buf(c).map_err(|path| Error::with_message(ErrorKind::Io, || format!("converting path to UTF-8: {path:?}")))
}
pub fn join < P1 : AsRef < Utf8Path > , P2 : AsRef < Utf8Path > > ( a : P1 , b : P2 ) -> Result < Utf8PathBuf > { let mut c = a . as_ref ( ) ; if c . extension ( ) . is_some ( ) { c = c . parent ( ) . ok_or_else ( | | Error :: with_message ( ErrorKind :: Io , | | " " ) ) ? ; // to directory } let mut c = PathBuf :: from ( c ) ; let b = b . as_ref ( ) ; c . append ( b ) . with_context ( ErrorKind :: Io , | | format ! ( " " ) ) ? ; Utf8PathBuf :: from_path_buf ( c ) . map_err ( | path | Error :: with_message ( ErrorKind :: Io , | | format ! ( " " ) ) ) }
Joins two files paths together
If the first path ends with a file name (i.e., the last component has a file extension),
the file component is dropped from that path.
Joins two files paths together If the first path ends with a file name ( i . e . the last component has a file extension ) the file component is dropped from that path .
a
P1
b
P2