rust-bindgen
rust-bindgen copied to clipboard
Support Clang parameter nullability attributes: _Nonnull & _Nullable for C headers
Swift imports C apis while taking into account clang nullability attributes: _Nullable & _Nonnull which results in Optional<UnsafePointer<T> and UnsafePointer<T> for the respective Swift generated C bindings, these should map to the Rust option equivalent
There was a previous attempt to use implement this feature https://github.com/rust-lang/rust-bindgen/issues/1876, however the title is wrong, as these are clang level annotations and not objective-c exclusive annotations, in other words, hey can work on any plain C header, and are independent from objective-c rust support
Sources:
- https://github.com/swiftlang/swift/blob/main/docs/HowSwiftImportsCAPIs.md#nullable-and-non-nullable-pointers
- https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes