struct PositionalNamedArgsLint {
positional_named_args: Vec<PositionalNamedArg>,
}
Expand description
Encapsulates all the named arguments that have been used positionally
Fields
positional_named_args: Vec<PositionalNamedArg>
Implementations
sourceimpl PositionalNamedArgsLint
impl PositionalNamedArgsLint
sourcefn maybe_add_positional_named_arg(
&mut self,
arg: Option<&FormatArg>,
ty: PositionalNamedArgType,
cur_piece: usize,
inner_span_to_replace: Option<InnerSpan>,
has_formatting: bool
)
fn maybe_add_positional_named_arg(
&mut self,
arg: Option<&FormatArg>,
ty: PositionalNamedArgType,
cur_piece: usize,
inner_span_to_replace: Option<InnerSpan>,
has_formatting: bool
)
For a given positional argument, check if the index is for a named argument.
Since positional arguments are required to come before named arguments, if the positional index is greater than or equal to the start of named arguments, we know it’s a named argument used positionally.
Example: println!(“{} {} {2}”, 0, a=1, b=2);
In this case, the first piece ({}
) would be ArgumentImplicitlyIs with an index of 0. The
total number of arguments is 3 and the number of named arguments is 2, so the start of named
arguments is index 1. Therefore, the index of 0 is okay.
The second piece ({}
) would be ArgumentImplicitlyIs with an index of 1, which is the start
of named arguments, and so we should add a lint to use the named argument a
.
The third piece ({2}
) would be ArgumentIs with an index of 2, which is greater than the
start of named arguments, and so we should add a lint to use the named argument b
.
This same check also works for width and precision formatting when either or both are CountIsParam, which contains an index into the arguments.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PositionalNamedArgsLint
impl !Send for PositionalNamedArgsLint
impl !Sync for PositionalNamedArgsLint
impl Unpin for PositionalNamedArgsLint
impl UnwindSafe for PositionalNamedArgsLint
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes