pub type Bool = u8;Expand description
Mirrors C Bool, which pounce.h — like Ipopt 3.14’s
IpStdCInterface.h — declares as the C99 bool. That is one byte,
so this is u8 and not c_int.
It was c_int until gh#624, i.e. four bytes on the Rust side against
one on every C caller’s, in both directions:
- a callback returning
falsesets onlyAL, and the x86-64 psABI leaves the rest ofEAXunspecified — read as ani32, a failed evaluation could come back nonzero, which reads as success. The solver would then accept a point it was told it could not evaluate instead of cutting the step. gcc and clang emitmovzbl, which is why this stayed latent rather than exploding; - an array of them would have been a hard stride bug, 1-byte
elements read at 4-byte spacing. That is why
IpoptSetNonlinearVariablestakes a count plus an index list rather than theBoolmask gh#624 originally proposed.
u8 rather than Rust’s bool on purpose: the two have identical
layout, but bool carries a validity invariant (it must hold 0 or
1), and a C caller reaching this boundary with anything else — an
older header where Bool was int, a hand-rolled binding, a value
that came through a memcpy — would be instant undefined behaviour.
u8 accepts whatever arrives and tests it the way C does, which is
the same reason the entry points validate rather than trust.