You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! Thank you for the great library I use Nix for all my projects.
I am trying to call nix::sys::statvfs::fstatvfs with signature: pub fn fstatvfs<T: AsRawFd>(fd: &T) -> Result<Statvfs>. I have a RawFd:
let fdref:RawFd = ...;match nix::sys::statvfs::fstatvfs(& fdref){
...}
Error:
error[E0277]: the trait bound `i32: std::os::unix::io::AsRawFd` is not satisfied
--> src/detfs.rs:992:15
|
992 | match nix::sys::statvfs::fstatvfs(& fdref) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::os::unix::io::AsRawFd` is not implemented for `i32`
|
= note: required by `nix::sys::statvfs::fstatvfs`
So it seems I cannot use a RawFd to call a function with T: AsRawFd trait bound?
I ended up wrapping my RawFd in a struct which implemented AsRawFd:
You aren't missing anything. The problem is that RawFd is defined as a type alias for i32, not a struct. So there's no way to add methods to it without also adding those methods to i32. rust-lang/rust#41035
Hello! Thank you for the great library I use Nix for all my projects.
I am trying to call
nix::sys::statvfs::fstatvfs
with signature:pub fn fstatvfs<T: AsRawFd>(fd: &T) -> Result<Statvfs>
. I have a RawFd:Error:
So it seems I cannot use a RawFd to call a function with T: AsRawFd trait bound?
I ended up wrapping my RawFd in a struct which implemented AsRawFd:
Which works, but is really weird to have to do. Am I missing something?
The text was updated successfully, but these errors were encountered: