rust-lang / rust-lang/rust-bindgen
Option for nopartialord
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
enum A {
A0 = 0,
A1 = 1,
};
struct B {
char *name;
unsigned age;
};
Bindgen Invocation
$ bindgen input.h --rustified-enum "*" --with-derive-partialeq --with-derive-partialord
Actual Results
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)]
pub enum A {
A0 = 0,
A1 = 1,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct B {
pub name: *mut ::std::os::raw::c_char,
pub age: ::std::os::raw::c_uint,
}
I get PartialOrd for enum A and struct B. That is fine for enum A since I need its elements to be comparable; but I don't want this behavior for struct B (e.g. name needs some special treatment for comparison).
Currently, we cannot enable PartialOrd on some types but disable on other types, so I've naively added this option
$bindgen input.h --rustified-enum '*' --with-derive-partialeq --with-derive-partialord --no-partialord B
Expected Results
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)]
pub enum A {
A0 = 0,
A1 = 1,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct B {
pub name: *mut ::std::os::raw::c_char,
pub age: ::std::os::raw::c_uint,
}
I don't know whether this behavior is something that bindgen want (or doesn't want) to cover, or there are details that I cannot see yet.
Many thanks for any comment.
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
Start with the bindgen command-line handling for --with-derive-partialord and the derive-selection path; the issue names no repository files or tests. Trace how --rustified-enum and --with-derive-partialord select types, then verify that --no-partialord B removes PartialOrd from B while leaving it on enum A.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100