brunoczim / fslock

File locking for Rust.
MIT License
40 stars 11 forks source link

Update unix.rs #2

Closed rakshith-ravi closed 4 years ago

rakshith-ravi commented 4 years ago

I haven't tested this yet. Just a proposal of what I think might be the fix

brunoczim commented 4 years ago

Hmm yes, your proposal looks good, but it still fails to compile.

error[E0308]: mismatched types
   --> src/unix.rs:228:23
    |
228 |         Ok(OsString { alloc, len })
    |                       ^^^^^ expected `u8`, found `i8`
    |
    = note: expected struct `std::ptr::NonNull<u8>`
               found struct `std::ptr::NonNull<i8>`

error[E0308]: mismatched types
   --> src/unix.rs:275:38
    |
275 |     Ok(EitherOsStr::Owned(OsString { alloc, len: slice.len() }))
    |                                      ^^^^^ expected `u8`, found `i8`
    |
    = note: expected struct `std::ptr::NonNull<u8>`
               found struct `std::ptr::NonNull<i8>`

error: aborting due to 2 previous errors

I think instead of defining the whole struct using a #[cfg], we could just define it using libc::c_char, which is the type that libc uses for C strings:


PS: `libc::c_char` is defined as `u8` on arm.
rakshith-ravi commented 4 years ago

No problem haha. I'm just happy to make this a better library to use :P

Thanks for merging it. Would you happen to be able to release it as well? Or is there a CI system that does it automatically?

brunoczim commented 4 years ago

I have released it a few minutes after the merge. And no, there is no CI for now, I have to learn GH tools for CI like travis, I am used to GitLab CI haha.

rakshith-ravi commented 4 years ago

Haha alright. Thanks a lot