Closed
Description
Whilst implementing wrappers around sysctl, I had to create a mutable value on the stack which would be overwritten by sysctl. To make the wrapper useful, I wanted to make it generic in <T: Default>
. For c_int, etc, this is fine, but structs like timeval
this isn't. Rust's rules mean I can't impl the Default trait to structs defined in libc.
My workaround is to have two wrapper functions, one which takes <T>
and has an extra user-supplied default, and one that takes <T: Default>
.
A simple solution to this would be to have the s! macro generate a default trait for all structs like this. In the near term, however, would you be open to this sort of change? Or is it something you don't feel belongs in libc?
Metadata
Metadata
Assignees
Labels
No labels