Skip to content

Commit

Permalink
test(derive): No longer supporting some wrapped types
Browse files Browse the repository at this point in the history
With the new `ArgMatches`, we need to know what the inner type is.

Unfortunately, #3142 didn't list use cases for this.  We dropped the
`Option` alias changing `T` but we still have a `Result` in there that
is aliased.

One potential workaround if people need it is if we add an attribute to
specify the `get_many::<T>` type.  This would also help with
`ArgAction::Count` to support more data types.
  • Loading branch information
epage committed Jun 13, 2022
1 parent 17dea9b commit 0b440d9
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions tests/derive/type_alias_regressions.rs
@@ -1,27 +1,13 @@
//! Regression test to ensure that type aliases do not cause compilation failures.
#![allow(deprecated)]

/// Regression test to ensure that type aliases do not cause compilation failures.
use std::str::FromStr;

use clap::{Parser, Subcommand, ValueEnum};

// Result type alias
#[allow(dead_code)]
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

// Wrapper to use for Option type alias
#[derive(Debug, PartialEq, Eq)]
struct Wrapper<T>(T);

impl<T: FromStr> FromStr for Wrapper<T> {
type Err = <T as FromStr>::Err;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
T::from_str(s).map(Wrapper)
}
}

type Option<T> = std::option::Option<Wrapper<T>>;
type Option<T> = std::option::Option<T>;

#[derive(Parser)]
pub struct Opts {
Expand Down

0 comments on commit 0b440d9

Please sign in to comment.