Struct rustpython_ast::Arguments
source · pub struct Arguments<R = TextRange> {
pub range: OptionalRange<R>,
pub posonlyargs: Vec<ArgWithDefault<R>>,
pub args: Vec<ArgWithDefault<R>>,
pub vararg: Option<Box<Arg<R>>>,
pub kwonlyargs: Vec<ArgWithDefault<R>>,
pub kwarg: Option<Box<Arg<R>>>,
}
Expand description
An alternative type of AST arguments
. This is parser-friendly and human-friendly definition of function arguments.
This form also has advantage to implement pre-order traverse.
defaults
and kw_defaults
fields are removed and the default values are placed under each arg_with_default
typed argument.
vararg
and kwarg
are still typed as arg
because they never can have a default value.
The matching Python style AST type is PythonArguments. While PythonArguments has ordered kwonlyargs
fields by
default existence, Arguments has location-ordered kwonlyargs fields.
NOTE: This type is different from original Python AST.
Fields§
§range: OptionalRange<R>
§posonlyargs: Vec<ArgWithDefault<R>>
§args: Vec<ArgWithDefault<R>>
§vararg: Option<Box<Arg<R>>>
§kwonlyargs: Vec<ArgWithDefault<R>>
§kwarg: Option<Box<Arg<R>>>
Implementations§
source§impl<R> Arguments<R>
impl<R> Arguments<R>
pub fn defaults(&self) -> impl Iterator<Item = &Expr<R>>
pub fn split_kwonlyargs(&self) -> (Vec<&Arg<R>>, Vec<(&Arg<R>, &Expr<R>)>)
pub fn to_python_arguments(&self) -> PythonArguments<R>where
R: Clone,
pub fn into_python_arguments(self) -> PythonArguments<R>
Trait Implementations§
source§impl<R> From<Arguments<R>> for PythonArguments<R>
impl<R> From<Arguments<R>> for PythonArguments<R>
impl<R> StructuralPartialEq for Arguments<R>
Auto Trait Implementations§
impl<R> Freeze for Arguments<R>
impl<R> RefUnwindSafe for Arguments<R>where
R: RefUnwindSafe,
impl<R> Send for Arguments<R>where
R: Send,
impl<R> Sync for Arguments<R>where
R: Sync,
impl<R> Unpin for Arguments<R>where
R: Unpin,
impl<R> UnwindSafe for Arguments<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more