Skip to content

Expanded RegEx Support? #2432

Open
Open
@hcldan

Description

@hcldan

@pvdrz
Following on the heels of #2328 ... I've changed to start using the new option and it's working great but I ran into a snag...

Some of the older c libs that I'm using have structs that don't always follow proper naming patterns.
Rather than having to exclude them from the bindgen, I'd like to just filter them from having a derive applied to them.

Here's a sample of the RegEx I was trying to use:
https://regex101.com/r/pjeUkB/1

Basically, If the struct starts with "My" and doesn't contain Foo in it, then apply the derive.
This doesn't seem to work, and seems to silently ignore the regex. Am I doing this wrong?

--with-derive-custom-struct '^My((?!Foo).)+$'=MyStructTrait

This doesn't seem to match anything. I have verified that this does though:

--with-derive-custom-struct '^My.+$'=MyStructTrait

But it matches the ones I don't want as well.
Does the regex impl in use not support lookahead or negative lookahead?

I would have expected the regex compile to fail or something.

Bindgen Invocation

--with-derive-custom-struct '^My((?!Foo).)+$'=MyStructTrait

Actual Results

No structs are labeled with a MyStructTrait derive.

Expected Results

I expect to see:

#[derive(MyStructTrait)]
struct MyStruct {}

struct MyFoo {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions