diff --git a/bench/src/main.rs b/bench/src/main.rs index 1a3a4a5..bf5fecf 100644 --- a/bench/src/main.rs +++ b/bench/src/main.rs @@ -39,12 +39,7 @@ fn main() { continue; } - 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()) @@ -137,7 +132,7 @@ fn get_files_recursively(dir_path: &PathBuf) -> Result, std::io::Er Ok(files) } -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 { diff --git a/measure_bytecode_size/src/main.rs b/measure_bytecode_size/src/main.rs index ad1e670..1bbc825 100644 --- a/measure_bytecode_size/src/main.rs +++ b/measure_bytecode_size/src/main.rs @@ -34,12 +34,7 @@ pub fn main() { continue; } - 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()) @@ -85,7 +80,7 @@ fn get_files_recursively(dir_path: impl AsRef) -> Result, std Ok(files) } -fn resolve_entry_path(entry_path: &String) -> ResolvedPath { +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 { diff --git a/valuescript_compiler/src/resolve_path.rs b/valuescript_compiler/src/resolve_path.rs index c4c5a8a..52ac6ed 100644 --- a/valuescript_compiler/src/resolve_path.rs +++ b/valuescript_compiler/src/resolve_path.rs @@ -17,7 +17,7 @@ impl std::fmt::Display for ResolvedPath { } } -pub fn resolve_path(importer_path: &ResolvedPath, path: &String) -> ResolvedPath { +pub fn resolve_path(importer_path: &ResolvedPath, path: &str) -> ResolvedPath { let importer_path_buf = PathBuf::from(&importer_path.path); let parent = importer_path_buf.parent().unwrap_or_else(|| Path::new("/")); diff --git a/vstc/src/resolve_entry_path.rs b/vstc/src/resolve_entry_path.rs index a439166..b2ec484 100644 --- a/vstc/src/resolve_entry_path.rs +++ b/vstc/src/resolve_entry_path.rs @@ -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 { diff --git a/vstc/src/test_inputs.rs b/vstc/src/test_inputs.rs index 6fc53bf..30b2cf8 100644 --- a/vstc/src/test_inputs.rs +++ b/vstc/src/test_inputs.rs @@ -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()) diff --git a/vstc/src/to_bytecode.rs b/vstc/src/to_bytecode.rs index 658bb32..1864308 100644 --- a/vstc/src/to_bytecode.rs +++ b/vstc/src/to_bytecode.rs @@ -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)