Add rust language editions support by nyurik · Pull Request #3000 · rust-lang/rust-bindgen (original) (raw)
Introduce a new --rust-edition
parameter with allowed values 2015, 2018, 2021, and 2024. This allows different code generation depending on the language target.
In this PR, the C-string literals are now generated differently depending on the language edition (literals like c"example"
are not available before 2021)
The default language edition uses logic:
- if
--rust-target
is before 1.31.0, use2015
- if
--rust-target
version is before 1.56.0, use2018
- use 2018 as default otherwise
In the future, it would be good to add these, if possible:
- if compiled as a cli utility, use 2018 to reduce compatibility issues (?)
- if used as a lib from
build.rs
, detect current edition (is this possible?), and use the one of thebuild.rs