Prefer str

This commit is contained in:
Andrew Morris
2023-11-02 10:22:30 +11:00
parent 92a52491ec
commit a5e76355f7
6 changed files with 10 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
use valuescript_compiler::{resolve_path, ResolvedPath};
pub fn resolve_entry_path(entry_path: &String) -> ResolvedPath {
pub fn resolve_entry_path(entry_path: &str) -> ResolvedPath {
// Like cwd (current working dir), but it's cwd/file.
// This is a bit of a hack so we can use resolve_path to get the absolute path of the entry point.
let cwd_file = ResolvedPath {

View File

@@ -54,12 +54,8 @@ mod tests {
failed_paths.insert(rel_file_path.clone());
}
let resolved_path = resolve_entry_path(
&file_path
.to_str()
.expect("Failed to convert to str")
.to_string(),
);
let resolved_path =
resolve_entry_path(file_path.to_str().expect("Failed to convert to str"));
let compile_result = compile(resolved_path, |path| {
fs::read_to_string(path).map_err(|err| err.to_string())

View File

@@ -7,7 +7,7 @@ use crate::{
handle_diagnostics_cli::handle_diagnostics_cli, resolve_entry_path::resolve_entry_path,
};
pub fn to_bytecode(format: RunFormat, file_path: &String) -> Bytecode {
pub fn to_bytecode(format: RunFormat, file_path: &str) -> Bytecode {
Bytecode::new(match format {
RunFormat::TypeScript => {
let resolved_entry_path = resolve_entry_path(file_path);
@@ -47,7 +47,7 @@ pub enum RunFormat {
Bytecode,
}
pub fn format_from_path(file_path: &String) -> RunFormat {
pub fn format_from_path(file_path: &str) -> RunFormat {
let ext = Path::new(&file_path)
.extension()
.and_then(OsStr::to_str)