pub fn resolve_bin(&self, parent: &Path) -> Option<(PathBuf, PathBuf)> {
        let main_path: PathBuf = self.main.clone().into();
        // If the main path is a valid SubPath, we just use that.
        if let Ok(s) = SubPath::from_path(&main_path) {
            if parent.join(&s.0).with_extension("idr").exists() {
                let target_path = if s.0.extension().is_none() {
                    parent.join(&s.0).with_extension("idr")
                } else {
                    parent.join(&s.0)
                };
                let src_path = target_path.parent().unwrap();
                // This is the relative target path
                let target_path: PathBuf = target_path.file_name().unwrap().to_os_string().into();
                return Some((src_path.to_path_buf(), target_path));
            }
        }

        // Otherwise, we have to do more complicated logic.
        let src_path = parent.join(&self.path.0);
        let mut split = self.main.trim_matches('.').rsplitn(2, '.');
        let (after, before) = (split.next().unwrap(), split.next());

        if let Some(before) = before {
            let target_path: PathBuf = before.replace(".", "/").into();
            // If there is at least one dot in the name:
            if src_path
                .join(&target_path)
                .join(after)
                .with_extension("idr")
                .exists()
            {
                // If a file corresponding to the whole module name exists, we use that.
                Some((src_path, target_path.join(after).with_extension("idr")))
            } else if src_path.join(&target_path).with_extension("idr").exists() {
                // Otherwise, if a file corresponding to the module name minus the last
                // part exists, we assume that the last part refers to a function which
                // should be treated as the main function.
                Some((src_path, target_path.with_extension(after)))
            } else {
                None
            }
        } else {
            let target_path: PathBuf = after.into();
            // Otherwise, if the name has no dots:
            if src_path.join(&target_path).with_extension("idr").exists() {
                Some((src_path, target_path.with_extension("idr")))
            } else {
                None
            }
        }
    }
// A note on extensions:
// - If the extension of the target_path is idr or empty, it will be treated as a Main file.
// - If the extension of the target_path is anything else, that extension will be the function
//   of the preceding part's module which will be treated as the main function.
A note on extensions:
If the extension of the target_path is idr or empty, it will be treated as a Main file.
If the extension of the target_path is anything else, that extension will be the function
of the preceding part's module which will be treated as the main function.
A note on extensions : If the extension of the target_path is idr or empty it will be treated as a Main file . If the extension of the target_path is anything else that extension will be the function of the preceding part ' s module which will be treated as the main function .
pub fn resolve_bin(&self, parent: &Path) -> Option<(PathBuf, PathBuf)> {
        let main_path: PathBuf = self.main.clone().into();
        // If the main path is a valid SubPath, we just use that.
        if let Ok(s) = SubPath::from_path(&main_path) {
            if parent.join(&s.0).with_extension("idr").exists() {
                let target_path = if s.0.extension().is_none() {
                    parent.join(&s.0).with_extension("idr")
                } else {
                    parent.join(&s.0)
                };
                let src_path = target_path.parent().unwrap();
                // This is the relative target path
                let target_path: PathBuf = target_path.file_name().unwrap().to_os_string().into();
                return Some((src_path.to_path_buf(), target_path));
            }
        }
        // Otherwise, we have to do more complicated logic.
        let src_path = parent.join(&self.path.0);
        let mut split = self.main.trim_matches('.').rsplitn(2, '.');
        let (after, before) = (split.next().unwrap(), split.next());
        if let Some(before) = before {
            let target_path: PathBuf = before.replace(".", "/").into();
            // If there is at least one dot in the name:
            if src_path
                .join(&target_path)
                .join(after)
                .with_extension("idr")
                .exists()
            {
                // If a file corresponding to the whole module name exists, we use that.
                Some((src_path, target_path.join(after).with_extension("idr")))
            } else if src_path.join(&target_path).with_extension("idr").exists() {
                // Otherwise, if a file corresponding to the module name minus the last
                // part exists, we assume that the last part refers to a function which
                // should be treated as the main function.
                Some((src_path, target_path.with_extension(after)))
            } else {
                None
            }
        } else {
            let target_path: PathBuf = after.into();
            // Otherwise, if the name has no dots:
            if src_path.join(&target_path).with_extension("idr").exists() {
                Some((src_path, target_path.with_extension("idr")))
            } else {
                None
            }
        }
    }
pub fn resolve_bin ( & self , parent : & Path ) -> Option < ( PathBuf , PathBuf ) > { let main_path : PathBuf = self . main . clone ( ) . into ( ) ; // If the main path is a valid SubPath, we just use that. if let Ok ( s ) = SubPath :: from_path ( & main_path ) { if parent . join ( & s . 0 ) . with_extension ( " " ) . exists ( ) { let target_path = if s . 0 . extension ( ) . is_none ( ) { parent . join ( & s . 0 ) . with_extension ( " " ) } else { parent . join ( & s . 0 ) } ; let src_path = target_path . parent ( ) . unwrap ( ) ; // This is the relative target path let target_path : PathBuf = target_path . file_name ( ) . unwrap ( ) . to_os_string ( ) . into ( ) ; return Some ( ( src_path . to_path_buf ( ) , target_path ) ) ; } } // Otherwise, we have to do more complicated logic. let src_path = parent . join ( & self . path . 0 ) ; let mut split = self . main . trim_matches ( '.' ) . rsplitn ( 2 , '.' ) ; let ( after , before ) = ( split . next ( ) . unwrap ( ) , split . next ( ) ) ; if let Some ( before ) = before { let target_path : PathBuf = before . replace ( " " , " " ) . into ( ) ; // If there is at least one dot in the name: if src_path . join ( & target_path ) . join ( after ) . with_extension ( " " ) . exists ( ) { // If a file corresponding to the whole module name exists, we use that. Some ( ( src_path , target_path . join ( after ) . with_extension ( " " ) ) ) } else if src_path . join ( & target_path ) . with_extension ( " " ) . exists ( ) { // Otherwise, if a file corresponding to the module name minus the last // part exists, we assume that the last part refers to a function which // should be treated as the main function. Some ( ( src_path , target_path . with_extension ( after ) ) ) } else { None } } else { let target_path : PathBuf = after . into ( ) ; // Otherwise, if the name has no dots: if src_path . join ( & target_path ) . with_extension ( " " ) . exists ( ) { Some ( ( src_path , target_path . with_extension ( " " ) ) ) } else { None } } }
A note on extensions:
 If the extension of the target_path is idr or empty, it will be treated as a Main file.
A note on extensions : If the extension of the target_path is idr or empty it will be treated as a Main file .
&self
parent
&Path