diff --git a/source/ports/rs_port/src/load.rs b/source/ports/rs_port/src/load.rs index 4c9f8cc55..b15fe81cd 100644 --- a/source/ports/rs_port/src/load.rs +++ b/source/ports/rs_port/src/load.rs @@ -9,53 +9,53 @@ use std::{ ptr, }; -/// Loads a script from a single file. Usage example: ... +/// Loads a path from a single file. Usage example: ... /// ``` -/// // A Nodejs script +/// // A Nodejs path /// metacall::load::from_single_file("node", "index.js").unwrap(); /// ``` pub fn from_single_file( tag: impl ToString, - script: impl AsRef, + path: impl AsRef, ) -> Result<(), MetaCallLoaderError> { - from_file(tag, [script]) + from_file(tag, [path]) } -/// Loads a script from file. Usage example: ... +/// Loads a path from file. Usage example: ... /// ``` -/// // A Nodejs script +/// // A Nodejs path /// metacall::load::from_file("node", ["index.js", "main.js"]).unwrap(); /// ``` pub fn from_file( tag: impl ToString, - scripts: impl IntoIterator>, + paths: impl IntoIterator>, ) -> Result<(), MetaCallLoaderError> { let c_tag = cstring_enum!(tag, MetaCallLoaderError)?; - let mut c_script: CString; + let mut c_path: CString; - let mut new_scripts: Vec<*const i8> = Vec::new(); - for script in scripts.into_iter() { - let script_as_pathbuf = PathBuf::from(script.as_ref()); - let script_as_str = script_as_pathbuf.to_str().unwrap(); + let mut new_paths: Vec<*const i8> = Vec::new(); + for path in paths.into_iter() { + let path_as_pathbuf = PathBuf::from(path.as_ref()); + let path_as_str = path_as_pathbuf.to_str().unwrap(); - if !script_as_pathbuf.exists() { - return Err(MetaCallLoaderError::FileNotFound(script_as_pathbuf)); + if !path_as_pathbuf.exists() { + return Err(MetaCallLoaderError::FileNotFound(path_as_pathbuf)); } - if !script_as_pathbuf.is_file() { + if !path_as_pathbuf.is_file() { return Err(MetaCallLoaderError::NotAFileOrPermissionDenied( - script_as_pathbuf, + path_as_pathbuf, )); } - c_script = cstring_enum!(script_as_str, MetaCallLoaderError)?; + c_path = cstring_enum!(path_as_str, MetaCallLoaderError)?; - new_scripts.push(c_script.as_ptr()); + new_paths.push(c_path.as_ptr()); } if unsafe { metacall_load_from_file( c_tag.as_ptr(), - new_scripts.as_mut_ptr(), - new_scripts.len(), + new_paths.as_mut_ptr(), + new_paths.len(), ptr::null_mut(), ) } != 0