From 6182ff951a741ad699ea6817f7d0ffffc54edfa9 Mon Sep 17 00:00:00 2001 From: ozwaldorf Date: Sun, 21 Jul 2024 14:59:19 -0400 Subject: [PATCH] fix: s/not/non/g --- bpaf_derive/src/attrs.rs | 10 +++++----- src/error.rs | 6 +++--- src/params.rs | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/bpaf_derive/src/attrs.rs b/bpaf_derive/src/attrs.rs index c7deeb35..07d808a5 100644 --- a/bpaf_derive/src/attrs.rs +++ b/bpaf_derive/src/attrs.rs @@ -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); @@ -257,7 +257,7 @@ pub(crate) enum PostParse { Optional { span: Span }, Parse { span: Span, f: Box }, Strict { span: Span }, - NotStrict { span: Span }, + NonStrict { span: Span }, Anywhere { span: Span }, } impl PostParse { @@ -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, } } @@ -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 } diff --git a/src/error.rs b/src/error.rs index f218d8bd..f07a1133 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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, String), @@ -92,7 +92,7 @@ impl Message { | Message::ParseFail(_) | Message::Missing(_) | Message::PureFailed(_) - | Message::NotStrictPos(_, _) => true, + | Message::NonStrictPos(_, _) => true, Message::StrictPos(_, _) | Message::ParseFailed(_, _) | Message::GuardFailed(_, _) @@ -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); diff --git a/src/params.rs b/src/params.rs index 09acd9a4..94fbc7ba 100644 --- a/src/params.rs +++ b/src/params.rs @@ -716,7 +716,7 @@ pub(crate) fn build_positional(metavar: &'static str) -> ParsePositional { /// 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 { metavar: &'static str, @@ -776,6 +776,7 @@ impl ParsePositional { /// `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 { ParsePositional { metavar: self.metavar, @@ -790,7 +791,8 @@ impl ParsePositional { /// 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 { + #[inline(always)] + pub fn non_strict(self) -> ParsePositional { ParsePositional { metavar: self.metavar, help: self.help, @@ -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 { - is_strict.then(|| Error(Message::NotStrictPos(ix, metavar))) + is_strict.then(|| Error(Message::NonStrictPos(ix, metavar))) } } @@ -886,6 +888,7 @@ where } } + #[inline(always)] fn meta(&self) -> Meta { self.meta() }