replaced references to core with references to crate

This commit is contained in:
Emma Tebibyte 2023-03-23 17:57:43 -04:00
parent ca16d4aa80
commit 42bb7655ba
Signed by: emma
GPG Key ID: 6D661C738815E7DD
4 changed files with 16 additions and 21 deletions

View File

@ -68,7 +68,7 @@ impl Args {
///On error returns pair: `(string index, Utf8Error)` ///On error returns pair: `(string index, Utf8Error)`
/// ///
///The function is safe as long as you pass C style main function arguments. ///The function is safe as long as you pass C style main function arguments.
pub unsafe fn new(argc: isize, argv: *const *const u8) -> Result<Self, (usize, core::str::Utf8Error)> { pub unsafe fn new(argc: isize, argv: *const *const u8) -> Result<Self, (usize, crate::str::Utf8Error)> {
assert!(argc > 0); assert!(argc > 0);
assert!(!argv.is_null()); assert!(!argv.is_null());
@ -102,7 +102,7 @@ impl Args {
///Returns slice of raw C strings ///Returns slice of raw C strings
pub fn as_slice(&self) -> &[*const u8] { pub fn as_slice(&self) -> &[*const u8] {
unsafe { unsafe {
core::slice::from_raw_parts(self.argv, self.argc) crate::slice::from_raw_parts(self.argv, self.argc)
} }
} }

View File

@ -79,10 +79,10 @@ unsafe fn invalid_cli_args_error() -> libc::c_int {
///Converts C string to Rust's, verifying it is UTF-8 ///Converts C string to Rust's, verifying it is UTF-8
/// ///
///It is UB to pass non-C string as it requires \0 ///It is UB to pass non-C string as it requires \0
pub unsafe fn c_str_to_rust(ptr: *const u8) -> Result<&'static str, core::str::Utf8Error> { pub unsafe fn c_str_to_rust(ptr: *const u8) -> Result<&'static str, crate::str::Utf8Error> {
let len = libc::strlen(ptr as *const i8); let len = libc::strlen(ptr as *const i8);
let parts = core::slice::from_raw_parts(ptr, len); let parts = crate::slice::from_raw_parts(ptr, len);
core::str::from_utf8(parts) crate::str::from_utf8(parts)
} }
///Converts C string to Rust's one assuming it is UTF-8 ///Converts C string to Rust's one assuming it is UTF-8