Add missing function with_style to the Builder

It's impossible to select desired style when cbindgen is configured from
the build script.
This commit is contained in:
Yury Mikhaylov
2020-10-09 17:50:51 -07:00
committed by Emilio Cobos Álvarez
parent e03830134b
commit 4be2fb4598
+20 -1
View File
@@ -6,7 +6,7 @@ use std::path;
use crate::bindgen::bindings::Bindings;
use crate::bindgen::cargo::Cargo;
use crate::bindgen::config::{Braces, Config, Language};
use crate::bindgen::config::{Braces, Config, Language, Style};
use crate::bindgen::error::Error;
use crate::bindgen::library::Library;
use crate::bindgen::parser::{self, Parse};
@@ -138,6 +138,12 @@ impl Builder {
self
}
#[allow(unused)]
pub fn with_style(mut self, style: Style) -> Builder {
self.config.style = style;
self
}
#[allow(unused)]
pub fn include_item<S: AsRef<str>>(mut self, item_name: S) -> Builder {
self.config
@@ -342,3 +348,16 @@ impl Builder {
.generate()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn with_style() {
assert_eq!(
Style::Tag,
Builder::new().with_style(Style::Tag).config.style
);
}
}