Skip to content

Commit 36431f4

Browse files
committed
Small code simplification
1 parent 330ecb1 commit 36431f4

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/main.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -931,34 +931,26 @@ where
931931
Ok(())
932932
}
933933

934-
/**
935-
Attempts to locate the script specified by the given path. If the path as-given doesn't yield anything, it will try adding file extensions.
936-
*/
934+
/// Attempts to locate the script specified by the given path.
937935
fn find_script<P>(path: P) -> Option<(PathBuf, fs::File)>
938936
where
939937
P: AsRef<Path>,
940938
{
941939
let path = path.as_ref();
942940

943-
// Try the path directly.
944941
if let Ok(file) = fs::File::open(path) {
945942
return Some((path.into(), file));
946943
}
947944

948-
// If it had an extension, don't bother trying any others.
949-
if path.extension().is_some() {
950-
return None;
951-
}
952-
953-
// Ok, now try other extensions.
954-
for &ext in &["ers", "rs"] {
955-
let path = path.with_extension(ext);
956-
if let Ok(file) = fs::File::open(&path) {
957-
return Some((path, file));
945+
if path.extension().is_none() {
946+
for &ext in &["ers", "rs"] {
947+
let path = path.with_extension(ext);
948+
if let Ok(file) = fs::File::open(&path) {
949+
return Some((path, file));
950+
}
958951
}
959952
}
960953

961-
// Welp. ¯\_(ツ)_/¯
962954
None
963955
}
964956

0 commit comments

Comments
 (0)