Skip to content

Commit

Permalink
fix: s/not/non/g
Browse files Browse the repository at this point in the history
  • Loading branch information
ozwaldorf committed Jul 21, 2024
1 parent 338cf8f commit 6182ff9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions bpaf_derive/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl ToTokens for PostParse {
PostParse::Optional { .. } => quote!(optional()),
PostParse::Parse { f, .. } => quote!(parse(#f)),
PostParse::Strict { .. } => quote!(strict()),
PostParse::NotStrict { .. } => quote!(not_strict()),
PostParse::NonStrict { .. } => quote!(non_strict()),
PostParse::Anywhere { .. } => quote!(anywhere()),
}
.to_tokens(tokens);
Expand Down Expand Up @@ -257,7 +257,7 @@ pub(crate) enum PostParse {
Optional { span: Span },
Parse { span: Span, f: Box<Expr> },
Strict { span: Span },
NotStrict { span: Span },
NonStrict { span: Span },
Anywhere { span: Span },
}
impl PostParse {
Expand All @@ -273,7 +273,7 @@ impl PostParse {
| Self::Optional { span }
| Self::Parse { span, .. }
| Self::Strict { span }
| Self::NotStrict { span }
| Self::NonStrict { span }
| Self::Anywhere { span } => *span,
}
}
Expand Down Expand Up @@ -483,8 +483,8 @@ impl PostParse {
Self::Parse { span, f }
} else if kw == "strict" {
Self::Strict { span }
} else if kw == "not_strict" {
Self::NotStrict { span }
} else if kw == "non_strict" {
Self::NonStrict { span }
} else if kw == "some" {
let msg = parse_arg(input)?;
Self::Some_ { span, msg }
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) enum Message {
StrictPos(usize, Metavar),

/// Tried to consume a non-strict positional argument, but the value was strict
NotStrictPos(usize, Metavar),
NonStrictPos(usize, Metavar),

/// Parser provided by user failed to parse a value
ParseFailed(Option<usize>, String),
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Message {
| Message::ParseFail(_)
| Message::Missing(_)
| Message::PureFailed(_)
| Message::NotStrictPos(_, _) => true,
| Message::NonStrictPos(_, _) => true,
Message::StrictPos(_, _)
| Message::ParseFailed(_, _)
| Message::GuardFailed(_, _)
Expand Down Expand Up @@ -331,7 +331,7 @@ impl Message {
}

// Error: FOO expected to be on the left side of --
Message::NotStrictPos(_ix, metavar) => {
Message::NonStrictPos(_ix, metavar) => {
doc.text("expected ");
doc.token(Token::BlockStart(Block::TermRef));
doc.metavar(metavar);
Expand Down
13 changes: 8 additions & 5 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ pub(crate) fn build_positional<T>(metavar: &'static str) -> ParsePositional<T> {
/// Parse a positional item, created with [`positional`](crate::positional)
///
/// You can add extra information to positional parsers with [`help`](Self::help),
/// [`strict`](Self::strict), or [`not_strict`](Self::not_strict) on this struct.
/// [`strict`](Self::strict), or [`non_strict`](Self::non_strict) on this struct.
#[derive(Clone)]
pub struct ParsePositional<T, R: PositionMarker = Unrestricted> {
metavar: &'static str,
Expand Down Expand Up @@ -776,6 +776,7 @@ impl<T> ParsePositional<T> {
/// `bpaf` would display such positional elements differently in usage line as well.
#[cfg_attr(not(doctest), doc = include_str!("docs2/positional_strict.md"))]
#[must_use]
#[inline(always)]
pub fn strict(self) -> ParsePositional<T, Strict> {
ParsePositional {
metavar: self.metavar,
Expand All @@ -790,7 +791,8 @@ impl<T> ParsePositional<T> {
/// Essentially the inverse operation to [`ParsePositional::strict`]. Can be used next to strict
/// positional arg(s) to have a clear separation and parsing between contexts.
#[must_use]
pub fn not_strict(self) -> ParsePositional<T, NotStrict> {
#[inline(always)]
pub fn non_strict(self) -> ParsePositional<T, NonStrict> {
ParsePositional {
metavar: self.metavar,
help: self.help,
Expand Down Expand Up @@ -818,11 +820,11 @@ pub struct Unrestricted;
impl PositionMarker for Unrestricted {}

/// Non-strict positional marker type
pub struct NotStrict;
impl PositionMarker for NotStrict {
pub struct NonStrict;
impl PositionMarker for NonStrict {
#[inline(always)]
fn check(metavar: Metavar, ix: usize, is_strict: bool) -> Option<Error> {
is_strict.then(|| Error(Message::NotStrictPos(ix, metavar)))
is_strict.then(|| Error(Message::NonStrictPos(ix, metavar)))
}
}

Expand Down Expand Up @@ -886,6 +888,7 @@ where
}
}

#[inline(always)]
fn meta(&self) -> Meta {
self.meta()
}
Expand Down

0 comments on commit 6182ff9

Please sign in to comment.