Skip to content

Commit 8725aea

Browse files
author
bors-servo
authored
Auto merge of rust-lang#1237 - osialr:feature/str-flags, r=emilio
Support str as input to Builder::no_* functions Previously, only String was supported on these while other functions in Builder worked with both str and String This tripped me up because `Builder::constified_enum_module` and `Builder::raw_line` worked with string slices but I got a compile error when I tried to use `Builder:;no_copy`
2 parents 4d1c954 + 8afc763 commit 8725aea

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1191,22 +1191,22 @@ impl Builder {
11911191

11921192
/// Don't derive `PartialEq` for a given type. Regular
11931193
/// expressions are supported.
1194-
pub fn no_partialeq(mut self, arg: String) -> Builder {
1195-
self.options.no_partialeq_types.insert(arg);
1194+
pub fn no_partialeq<T: Into<String>>(mut self, arg: T) -> Builder {
1195+
self.options.no_partialeq_types.insert(arg.into());
11961196
self
11971197
}
11981198

11991199
/// Don't derive `Copy` for a given type. Regular
12001200
/// expressions are supported.
1201-
pub fn no_copy(mut self, arg: String) -> Self {
1202-
self.options.no_copy_types.insert(arg);
1201+
pub fn no_copy<T: Into<String>>(mut self, arg: T) -> Self {
1202+
self.options.no_copy_types.insert(arg.into());
12031203
self
12041204
}
12051205

12061206
/// Don't derive `Hash` for a given type. Regular
12071207
/// expressions are supported.
1208-
pub fn no_hash(mut self, arg: String) -> Builder {
1209-
self.options.no_hash_types.insert(arg);
1208+
pub fn no_hash<T: Into<String>>(mut self, arg: T) -> Builder {
1209+
self.options.no_hash_types.insert(arg.into());
12101210
self
12111211
}
12121212
}

src/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,19 @@ where
589589

590590
if let Some(no_partialeq) = matches.values_of("no-partialeq") {
591591
for regex in no_partialeq {
592-
builder = builder.no_partialeq(String::from(regex));
592+
builder = builder.no_partialeq(regex);
593593
}
594594
}
595595

596596
if let Some(no_copy) = matches.values_of("no-copy") {
597597
for regex in no_copy {
598-
builder = builder.no_copy(String::from(regex));
598+
builder = builder.no_copy(regex);
599599
}
600600
}
601601

602602
if let Some(no_hash) = matches.values_of("no-hash") {
603603
for regex in no_hash {
604-
builder = builder.no_hash(String::from(regex));
604+
builder = builder.no_hash(regex);
605605
}
606606
}
607607

0 commit comments

Comments
 (0)