Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for #116.
The
libc
crate is supposed to provide a Rust type corresponding to each C type that might appear in a public API, for use in making foreign calls. However,libc
doesn't provide any type designated to correspond to a Cbool
.In practice, Rust's
bool
and thebool
of every C ABI I'm aware of are the same, so using the Rustbool
directly in foreign function interfaces will work fine on these systems. But thelibc
crate's principle is to provide types that match by definition, which isn't true of Rustbool
, solibc::c_bool
is still valuable.I considered whether it was better to let
c_bool
beu8
orbool
. In both C and C++, converting a value to abool
forces it to be either zero or one. Using Rustbool
forc_bool
mimics this behavior, whereasu8
would allow Rust code to pass other values. I think forcing a Cbool
to a value other than zero or one is undefined behavior, but I can't find the language to that effect right now. Either way, it seems like Rust'sbool
is the better match.