Remove unnecessary Box::new().

This commit is contained in:
Stephen Chung
2021-06-29 21:58:05 +08:00
parent 8b0299077b
commit bd35999b75
4 changed files with 28 additions and 27 deletions

View File

@@ -345,17 +345,19 @@ impl ModuleResolver for FileModuleResolver {
let file_path = self.get_file_path(path, source_path);
// Load the script file and compile it
match engine.compile_file(file_path).map_err(|err| match *err {
EvalAltResult::ErrorSystem(_, err) if err.is::<IoError>() => {
Box::new(EvalAltResult::ErrorModuleNotFound(path.to_string(), pos))
}
_ => Box::new(EvalAltResult::ErrorInModule(path.to_string(), err, pos)),
}) {
Ok(mut ast) => {
ast.set_source(path);
Some(Ok(ast))
}
err => Some(err),
}
Some(
engine
.compile_file(file_path)
.map(|mut ast| {
ast.set_source(path);
ast
})
.map_err(|err| match *err {
EvalAltResult::ErrorSystem(_, err) if err.is::<IoError>() => {
EvalAltResult::ErrorModuleNotFound(path.to_string(), pos).into()
}
_ => EvalAltResult::ErrorInModule(path.to_string(), err, pos).into(),
}),
)
}
}