Skip to content

Commit 1d8de67

Browse files
committed
make RegexSet non-public
1 parent 0f9dcdb commit 1d8de67

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

bindgen/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub use ir::annotations::FieldVisibilityKind;
5555
pub use ir::function::Abi;
5656
#[cfg(feature = "__cli")]
5757
pub use options::cli::builder_from_flags;
58-
pub use regex_set::RegexSet;
5958

6059
use codegen::CodegenError;
6160
use features::RustFeatures;

bindgen/options/as_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::PathBuf;
22

3-
use crate::RegexSet;
3+
use crate::regex_set::RegexSet;
44

55
/// Trait used to turn [`crate::BindgenOptions`] fields into CLI args.
66
pub(super) trait AsArgs {

bindgen/options/cli.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use crate::{
44
AttributeInfo, DeriveInfo, ItemInfo, ParseCallbacks, TypeKind,
55
},
66
features::RUST_TARGET_STRINGS,
7+
regex_set::RegexSet,
78
Abi, AliasVariation, Builder, CodegenConfig, EnumVariation,
89
FieldVisibilityKind, Formatter, MacroTypeVariation, NonCopyUnionStyle,
9-
RegexSet, RustTarget, DEFAULT_ANON_FIELDS_PREFIX,
10+
RustTarget, DEFAULT_ANON_FIELDS_PREFIX,
1011
};
1112
use clap::{
1213
error::{Error, ErrorKind},
@@ -1180,7 +1181,7 @@ where
11801181
let name = emit_diagnostics.then_some(_name);
11811182

11821183
for (derives, regex) in custom_derives {
1183-
let mut regex_set = RegexSet::new();
1184+
let mut regex_set = RegexSet::default();
11841185
regex_set.insert(regex);
11851186

11861187
#[cfg(feature = "experimental")]
@@ -1258,7 +1259,7 @@ where
12581259
let name = emit_diagnostics.then_some(_name);
12591260

12601261
for (attributes, regex) in custom_attributes {
1261-
let mut regex_set = RegexSet::new();
1262+
let mut regex_set = RegexSet::default();
12621263
regex_set.insert(regex);
12631264

12641265
#[cfg(feature = "experimental")]

bindgen/regex_set.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::cell::Cell;
66

77
/// A dynamic set of regular expressions.
88
#[derive(Clone, Debug, Default)]
9-
pub struct RegexSet {
9+
pub(crate) struct RegexSet {
1010
items: Vec<Box<str>>,
1111
/// Whether any of the items in the set was ever matched. The length of this
1212
/// vector is exactly the length of `items`.
@@ -17,18 +17,13 @@ pub struct RegexSet {
1717
}
1818

1919
impl RegexSet {
20-
/// Create a new RegexSet
21-
pub fn new() -> RegexSet {
22-
RegexSet::default()
23-
}
24-
2520
/// Is this set empty?
26-
pub fn is_empty(&self) -> bool {
21+
pub(crate) fn is_empty(&self) -> bool {
2722
self.items.is_empty()
2823
}
2924

3025
/// Insert a new regex into this set.
31-
pub fn insert<S>(&mut self, string: S)
26+
pub(crate) fn insert<S>(&mut self, string: S)
3227
where
3328
S: AsRef<str>,
3429
{
@@ -38,13 +33,13 @@ impl RegexSet {
3833
}
3934

4035
/// Returns slice of String from its field 'items'
41-
pub fn get_items(&self) -> &[Box<str>] {
36+
pub(crate) fn get_items(&self) -> &[Box<str>] {
4237
&self.items
4338
}
4439

4540
/// Returns an iterator over regexes in the set which didn't match any
4641
/// strings yet.
47-
pub fn unmatched_items(&self) -> impl Iterator<Item = &str> {
42+
pub(crate) fn unmatched_items(&self) -> impl Iterator<Item = &str> {
4843
self.items.iter().enumerate().filter_map(move |(i, item)| {
4944
if !self.record_matches || self.matched[i].get() {
5045
return None;
@@ -59,7 +54,8 @@ impl RegexSet {
5954
/// Must be called before calling `matches()`, or it will always return
6055
/// false.
6156
#[inline]
62-
pub fn build(&mut self, record_matches: bool) {
57+
#[allow(unused)]
58+
pub(crate) fn build(&mut self, record_matches: bool) {
6359
self.build_inner(record_matches, None)
6460
}
6561

@@ -70,7 +66,7 @@ impl RegexSet {
7066
/// Must be called before calling `matches()`, or it will always return
7167
/// false.
7268
#[inline]
73-
pub fn build_with_diagnostics(
69+
pub(crate) fn build_with_diagnostics(
7470
&mut self,
7571
record_matches: bool,
7672
name: Option<&'static str>,
@@ -114,7 +110,7 @@ impl RegexSet {
114110
}
115111

116112
/// Does the given `string` match any of the regexes in this set?
117-
pub fn matches<S>(&self, string: S) -> bool
113+
pub(crate) fn matches<S>(&self, string: S) -> bool
118114
where
119115
S: AsRef<str>,
120116
{

0 commit comments

Comments
 (0)