Skip to content

Commit eb8d919

Browse files
committed
perf: further debloating by removing generics from error cases
1 parent 7ac5a5a commit eb8d919

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

src/errors.rs

+14-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::process;
88
use std::result::Result as StdResult;
99

1010
// Internal
11-
use args::{AnyArg, FlagBuilder};
11+
use args::AnyArg;
1212
use fmt::{ColorWhen, Colorizer, ColorizerOption};
1313
use suggestions;
1414

@@ -404,14 +404,13 @@ impl Error {
404404
pub fn write_to<W: Write>(&self, w: &mut W) -> io::Result<()> { write!(w, "{}", self.message) }
405405

406406
#[doc(hidden)]
407-
pub fn argument_conflict<'a, 'b, A, O, U>(
408-
arg: &A,
407+
pub fn argument_conflict<'a, 'b, O, U>(
408+
arg: &AnyArg,
409409
other: Option<O>,
410410
usage: U,
411411
color: ColorWhen,
412412
) -> Self
413413
where
414-
A: AnyArg<'a, 'b> + Display,
415414
O: Into<String>,
416415
U: Display,
417416
{
@@ -444,9 +443,8 @@ impl Error {
444443
}
445444

446445
#[doc(hidden)]
447-
pub fn empty_value<'a, 'b, A, U>(arg: &A, usage: U, color: ColorWhen) -> Self
446+
pub fn empty_value<'a, 'b, U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
448447
where
449-
A: AnyArg<'a, 'b> + Display,
450448
U: Display,
451449
{
452450
let c = Colorizer::new(ColorizerOption {
@@ -470,17 +468,16 @@ impl Error {
470468
}
471469

472470
#[doc(hidden)]
473-
pub fn invalid_value<'a, 'b, B, G, A, U>(
471+
pub fn invalid_value<'a, 'b, B, G, U>(
474472
bad_val: B,
475473
good_vals: &[G],
476-
arg: &A,
474+
arg: &AnyArg,
477475
usage: U,
478476
color: ColorWhen,
479477
) -> Self
480478
where
481479
B: AsRef<str>,
482480
G: AsRef<str> + Display,
483-
A: AnyArg<'a, 'b> + Display,
484481
U: Display,
485482
{
486483
let c = Colorizer::new(ColorizerOption {
@@ -660,10 +657,9 @@ impl Error {
660657
}
661658

662659
#[doc(hidden)]
663-
pub fn too_many_values<'a, 'b, V, A, U>(val: V, arg: &A, usage: U, color: ColorWhen) -> Self
660+
pub fn too_many_values<'a, 'b, V, U>(val: V, arg: &AnyArg, usage: U, color: ColorWhen) -> Self
664661
where
665662
V: AsRef<str> + Display + ToOwned,
666-
A: AnyArg<'a, 'b> + Display,
667663
U: Display,
668664
{
669665
let v = val.as_ref();
@@ -689,15 +685,14 @@ impl Error {
689685
}
690686

691687
#[doc(hidden)]
692-
pub fn too_few_values<'a, 'b, A, U>(
693-
arg: &A,
688+
pub fn too_few_values<'a, 'b, U>(
689+
arg: &AnyArg,
694690
min_vals: u64,
695691
curr_vals: usize,
696692
usage: U,
697693
color: ColorWhen,
698694
) -> Self
699695
where
700-
A: AnyArg<'a, 'b> + Display,
701696
U: Display,
702697
{
703698
let c = Colorizer::new(ColorizerOption {
@@ -724,9 +719,7 @@ impl Error {
724719
}
725720

726721
#[doc(hidden)]
727-
pub fn value_validation<'a, 'b, A>(arg: Option<&A>, err: String, color: ColorWhen) -> Self
728-
where
729-
A: AnyArg<'a, 'b> + Display,
722+
pub fn value_validation<'a, 'b>(arg: Option<&AnyArg>, err: String, color: ColorWhen) -> Self
730723
{
731724
let c = Colorizer::new(ColorizerOption {
732725
use_stderr: true,
@@ -750,21 +743,20 @@ impl Error {
750743

751744
#[doc(hidden)]
752745
pub fn value_validation_auto(err: String) -> Self {
753-
let n: Option<&FlagBuilder> = None;
746+
let n: Option<&AnyArg> = None;
754747
Error::value_validation(n, err, ColorWhen::Auto)
755748
}
756749

757750
#[doc(hidden)]
758-
pub fn wrong_number_of_values<'a, 'b, A, S, U>(
759-
arg: &A,
751+
pub fn wrong_number_of_values<'a, 'b, S, U>(
752+
arg: &AnyArg,
760753
num_vals: u64,
761754
curr_vals: usize,
762755
suffix: S,
763756
usage: U,
764757
color: ColorWhen,
765758
) -> Self
766759
where
767-
A: AnyArg<'a, 'b> + Display,
768760
S: Display,
769761
U: Display,
770762
{
@@ -792,9 +784,8 @@ impl Error {
792784
}
793785

794786
#[doc(hidden)]
795-
pub fn unexpected_multiple_usage<'a, 'b, A, U>(arg: &A, usage: U, color: ColorWhen) -> Self
787+
pub fn unexpected_multiple_usage<'a, 'b, U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
796788
where
797-
A: AnyArg<'a, 'b> + Display,
798789
U: Display,
799790
{
800791
let c = Colorizer::new(ColorizerOption {

0 commit comments

Comments
 (0)