rust-lang / rust-lang/rust-bindgen
Make it possible so that function pointers aren't always wrapped in an Option.
Nobody has claimed this yet.
- #2370 by @pvdrz — closed without merging
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
I'm working on bindings of a C library (OpenUCX) where the majority, but not all, of function pointers used are never null (both typedefs and struct fields) - hence they shouldn't be generated as Option<extern fn ...> but as extern fn .... A very small number, however, can be null, and so needs to stay as Option<extern fn ..>. It'd be nice to do this via bindgen. Currently I post-process them using bindgen-wrapper (a horribly brittle tool of my own devising).
Would it possible for bindgen to take a list to override this behaviour, of structs and typedefs?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named in the issue. Start by reviewing bindgen's function-pointer generation and its handling of struct fields and typedefs; done means users can override nullability for selected declarations without post-processing, while preserving Option for declarations that may be null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100