Skip to content

Commit

Permalink
fix: s/R/P/g generics
Browse files Browse the repository at this point in the history
  • Loading branch information
ozwaldorf committed Jul 21, 2024
1 parent 6182ff9 commit 917e01f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ pub(crate) fn build_positional<T>(metavar: &'static str) -> ParsePositional<T> {
/// You can add extra information to positional parsers with [`help`](Self::help),
/// [`strict`](Self::strict), or [`non_strict`](Self::non_strict) on this struct.
#[derive(Clone)]
pub struct ParsePositional<T, R: PositionMarker = Unrestricted> {
pub struct ParsePositional<T, P: PositionMarker = Unrestricted> {
metavar: &'static str,
help: Option<Doc>,
ty: PhantomData<(T, R)>,
ty: PhantomData<(T, P)>,
}

impl<T, R: PositionMarker> ParsePositional<T, R> {
impl<T, P: PositionMarker> ParsePositional<T, P> {
/// Add a help message to a [`positional`] parser
///
/// `bpaf` converts doc comments and string into help by following those rules:
Expand All @@ -747,7 +747,7 @@ impl<T, R: PositionMarker> ParsePositional<T, R> {
}

fn meta(&self) -> Meta {
R::map_meta(Meta::from(Item::Positional {
P::map_meta(Meta::from(Item::Positional {
metavar: Metavar(self.metavar),
help: self.help.clone(),
}))
Expand Down Expand Up @@ -843,14 +843,14 @@ impl PositionMarker for Strict {
}
}

fn parse_pos_word<R: PositionMarker>(
fn parse_pos_word<P: PositionMarker>(
args: &mut State,
metavar: Metavar,
help: &Option<Doc>,
) -> Result<OsString, Error> {
match args.take_positional_word(metavar) {
Ok((ix, is_strict, word)) => {
if let Some(err) = R::check(metavar, ix, is_strict) {
if let Some(err) = P::check(metavar, ix, is_strict) {
#[cfg(feature = "autocomplete")]
args.push_pos_sep();
return Err(err);
Expand All @@ -874,14 +874,14 @@ fn parse_pos_word<R: PositionMarker>(
}
}

impl<T, R> Parser<T> for ParsePositional<T, R>
impl<T, P> Parser<T> for ParsePositional<T, P>
where
T: FromStr + 'static,
<T as std::str::FromStr>::Err: std::fmt::Display,
R: PositionMarker,
P: PositionMarker,
{
fn eval(&self, args: &mut State) -> Result<T, Error> {
let os = parse_pos_word::<R>(args, Metavar(self.metavar), &self.help)?;
let os = parse_pos_word::<P>(args, Metavar(self.metavar), &self.help)?;
match parse_os_str::<T>(os) {
Ok(ok) => Ok(ok),
Err(err) => Err(Error(Message::ParseFailed(args.current, err))),
Expand Down

0 comments on commit 917e01f

Please sign in to comment.