fn find_module(source_path: &Path, module_name: &str) -> Fallible<PathBuf> {
    let mut path = source_path.to_owned();
    //Pop the file name so we have just the directory path
    path.pop();
    path.push(format!("{}.rs", module_name));
    if path.exists() {
        return Ok(path);
    }
    path.pop();
    path.push(format!("{}/mod.rs", module_name));
    if path.exists() {
        return Ok(path);
    }

    //Else, could not find the module's source code
    bail!("Unable to locate source code for module '{}'", module_name);
}
/// Given the path to a source file containing a `mod` item, and the name of the module, attempts
/// to find the source file which contains that module.  It does this by trying first to find a
/// file `$MODNAME.rs` in the same directory as `source_path`, and failing that will look for
/// `$MODNAME/mod.rs`.  If either of those exises, the path to the file is returned, but no attempt
/// is made to determine if it's valid Rust code.
///
/// If it fails, returns a descriptive error
Given the path to a source file containing a `mod` item, and the name of the module, attempts
to find the source file which contains that module.

If it fails, returns a descriptive error
Given the path to a source file containing a ` mod ` item and the name of the module attempts to find the source file which contains that module . If it fails returns a descriptive error
fn find_module(source_path: &Path, module_name: &str) -> Fallible<PathBuf> {
    let mut path = source_path.to_owned();
    //Pop the file name so we have just the directory path
    path.pop();
    path.push(format!("{}.rs", module_name));
    if path.exists() {
        return Ok(path);
    }
    path.pop();
    path.push(format!("{}/mod.rs", module_name));
    if path.exists() {
        return Ok(path);
    }
    //Else, could not find the module's source code
    bail!("Unable to locate source code for module '{}'", module_name);
}
fn find_module ( source_path : & Path , module_name : & str ) -> Fallible < PathBuf > { let mut path = source_path . to_owned ( ) ; //Pop the file name so we have just the directory path path . pop ( ) ; path . push ( format ! ( " " module_name ) ) ; if path . exists ( ) { return Ok ( path ) ; } path . pop ( ) ; path . push ( format ! ( " " module_name ) ) ; if path . exists ( ) { return Ok ( path ) ; } //Else, could not find the module's source code bail ! ( " " module_name ) ; }
Given the path to a source file containing a `mod` item, and the name of the module, attempts
to find the source file which contains that module.
Given the path to a source file containing a ` mod ` item and the name of the module attempts to find the source file which contains that module .
source_path
&Path
module_name
&str
source_path
&Path
module_name
&str