Repository: mozilla/cbindgen (language: rust)

Issue:
Config (still) has private fields in `0.26`
See #841 .

This is still broken in `0.26`. This makes `Builder::with_config()` a PITA to use.

```rust
    cbindgen::Builder::new()
        .with_crate(std::env::var("CARGO_MANIFEST_DIR").unwrap())
        .with_config(cbindgen::Config {
            language: cbindgen::Language::C,
            braces: cbindgen::Braces::SameLine,
            cpp_compat: true,
            style: cbindgen::Style::Both,
            ..Default::default()
        })
        .generate()?
        .write_to_file("binding.h");
```

```
error[E0451]: field `config_path` of struct `Config` is private
   --> foo/build.rs:104:15
    |
104 |             ..Default::default()
    |               ^^^^^^^^^^^^^^^^^^ field `config_path` is private
```


Discussion / hints:
`cbindgen` follows cargo semver, so version 0.25 -> 0.26 allows breaking changes. The previous issue was because 0.25.x -> 0.25.y should not contain any breaking changes.
I opened the issue not to report a breaking API change but what I (and others, see #841) deem a questionable API design decision.

That it is a breaking change is perfectly acceptable per se, just not the reason why. 😉
Basically, this forces one to do this:

```rust
    cbindgen::Builder::new()
        .with_crate(std::env::var("CARGO_MANIFEST_DIR").unwrap())
        .with_config({
            let mut config = cbindgen::Config::default();
            
            config.language = cbindgen::Language::C;
            config.braces = cbindgen::Braces::SameLine;
            config.cpp_compat = true;
            config.style = cbindgen::Style::Both;
            
            config
        })
        .generate()?
        .write_to_file("binding.h");
```

This is neither canonical Rust nor the intended use of the [init-struct-pattern](https://xaeroxe.github.io/init-struct-pattern/) employed here.

Suggestion: separate the internally used (private) config struct from the public one used to configure the binding generator.

Fix patch:
diff --git a/CHANGES b/CHANGES
index c81b81e09..cb56b372f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+# unreleased
+
+      * Revert: The `Config` struct now has a private member.
+
 # 0.26.0
 
       * Fix swapping of `>>=` and `<<=` in constants.
diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs
index 5012414b7..a976d1d26 100644
--- a/src/bindgen/config.rs
+++ b/src/bindgen/config.rs
@@ -1010,8 +1010,15 @@ pub struct Config {
     pub only_target_dependencies: bool,
     /// Configuration options specific to Cython.
     pub cython: CythonConfig,
+    #[doc(hidden)]
     #[serde(skip)]
-    pub(crate) config_path: Option<StdPathBuf>,
+    /// Internal field for tracking from which file the config was loaded.
+    ///
+    /// Users should not set this field explicitly. Making the field private
+    /// prevents users from filling the struct with `..Default::default()`,
+    /// and creating a new InternalConfig struct would require more breaking
+    /// changes to our public API.
+    pub config_path: Option<StdPathBuf>,
 }
 
 impl Default for Config {


Test patch: