Struct ParametersSpec

Source
#[repr(C)]
pub struct ParametersSpec<V> { /* private fields */ }
Expand description

Define a list of parameters. This code assumes that all names are distinct and that *args/**kwargs occur in well-formed locations.

Implementations§

Source§

impl<V> ParametersSpec<V>

Source

pub fn new_parts<'a>( function_name: &str, pos_only: impl IntoIterator<Item = (&'a str, ParametersSpecParam<V>)>, pos_or_named: impl IntoIterator<Item = (&'a str, ParametersSpecParam<V>)>, args: bool, named_only: impl IntoIterator<Item = (&'a str, ParametersSpecParam<V>)>, kwargs: bool, ) -> ParametersSpec<V>
where V: Copy,

Create a new ParametersSpec.

Source

pub fn new_named_only<'a>( function_name: &str, named_only: impl IntoIterator<Item = (&'a str, ParametersSpecParam<V>)>, ) -> ParametersSpec<V>
where V: Copy,

Parameter parse with only named parameters.

Source

pub fn signature(&self) -> String

Produce an approximate signature for the function, combining the name and arguments.

Source

pub fn parameters_str(&self) -> String

Function parameter as they would appear in def (excluding types, default values and formatting).

Source§

impl<'v, V: ValueLike<'v>> ParametersSpec<V>

Source

pub fn len(&self) -> usize

Number of function parameters.

Source§

impl<'v, V: ValueLike<'v>> ParametersSpec<V>

Source

pub fn collect_into<const N: usize>( &self, args: &Arguments<'v, '_>, heap: &'v Heap, ) -> Result<[Option<Value<'v>>; N]>

Collect N arguments.

This function is called by generated code.

Source

pub fn collect( &self, args: &Arguments<'v, '_>, slots: &mut [Option<Value<'v>>], heap: &'v Heap, ) -> Result<()>

Move parameters from Arguments to a list of Value, using the supplied ParametersSpec.

Source

pub fn documentation( &self, parameter_types: Vec<Ty>, parameter_docs: HashMap<String, Option<DocString>>, ) -> DocParams

Generate documentation for each of the parameters.

§Arguments
  • parameter_types should be a mapping of parameter index to type
  • parameter_docs should be a mapping of parameter name to possible documentation for that parameter
Source

pub fn parser<R, F>( &self, args: &Arguments<'v, '_>, eval: &mut Evaluator<'v, '_, '_>, k: F, ) -> Result<R>
where F: FnOnce(&mut ParametersParser<'v, '_>, &mut Evaluator<'v, '_, '_>) -> Result<R>,

Create a ParametersParser for given arguments.

Source

pub fn can_fill_with_args(&self, pos: usize, names: &[&str]) -> bool

Check if current parameters can be filled with given arguments signature.

Trait Implementations§

Source§

impl<V: Allocative> Allocative for ParametersSpec<V>

Source§

fn visit<'allocative_a, 'allocative_b: 'allocative_a>( &self, visitor: &'allocative_a mut Visitor<'allocative_b>, )

Source§

impl<V: Clone> Clone for ParametersSpec<V>

Source§

fn clone(&self) -> ParametersSpec<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for ParametersSpec<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Freeze> Freeze for ParametersSpec<V>

Source§

type Frozen = ParametersSpec<<V as Freeze>::Frozen>

When type is frozen, it is frozen into this type.
Source§

fn freeze(self, freezer: &Freezer) -> FreezeResult<Self::Frozen>

Freeze a value. The frozen value must be equal to the original, and produce the same hash. Read more
Source§

impl<'v, V: Trace<'v>> Trace<'v> for ParametersSpec<V>

Source§

fn trace(&mut self, tracer: &Tracer<'v>)

Recursively “trace” the value. Read more

Auto Trait Implementations§

§

impl<V> Freeze for ParametersSpec<V>

§

impl<V> RefUnwindSafe for ParametersSpec<V>
where V: RefUnwindSafe,

§

impl<V> Send for ParametersSpec<V>
where V: Send,

§

impl<V> Sync for ParametersSpec<V>
where V: Sync,

§

impl<V> Unpin for ParametersSpec<V>

§

impl<V> UnwindSafe for ParametersSpec<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,