Skip to main content

Arg

Struct Arg 

Source
pub struct Arg {
    pub origin: Origin,
    pub data: Cell,
}
Expand description

A wrapper for a Cell that is intended to be an argument of a function or an operator.

Fields§

§origin: Origin

The range in the Rust or Script source code that spans the location of the argument’s application.

§data: Cell

The actual argument data.

Implementations§

Source§

impl Arg

Source

pub fn new(origin: Origin, data: Cell) -> Self

A convenient constructor for creating an Arg.

Source

pub fn provider(&mut self) -> Provider<'_>

Returns a borrowed Provider of the argument’s data Cell.

This function is useful for downcasting the argument into a Rust reference:

<&usize>::downcast(origin, arg.provider()).

Note that downcasting may render the argument’s data obsolete. Therefore, you shouldn’t use this Cell again. If needed, clone the Arg or the data Cell of this Arg object.

Source

pub fn into_provider<'a>(self) -> Provider<'a>

Returns an owned Provider of the argument’s data Cell.

This function is useful for downcasting the argument into a Rust-owned data:

<usize>::downcast(origin, arg.into_provider()).

Source

pub fn split(self) -> (Origin, Cell)

A helper function that splits an Arg into a tuple of origin and data.

Source

pub fn take(arguments: &mut [Self], index: usize) -> Self

A helper function that retrieves an argument by index from an array of arguments.

This function returns an Arg object at arguments[index], replacing the original Cell with Cell::nil.

§Panics

This function panics if the index is greater than or equal to the length of arguments.

Source

pub unsafe fn take_unchecked(arguments: &mut [Self], index: usize) -> Self

An unsafe version of the Arg::take function.

Unlike the safe take function, the take_unchecked function does not check the arguments boundaries in production builds. As a result, it does not panic if the index exceeds the length of the input array.

§Safety

The index must be less than arguments.len().

Trait Implementations§

Source§

impl Clone for Arg

Source§

fn clone(&self) -> Arg

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Arg

Source§

fn default() -> Arg

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Arg

§

impl !UnwindSafe for Arg

§

impl Freeze for Arg

§

impl Send for Arg

§

impl Sync for Arg

§

impl Unpin for Arg

§

impl UnsafeUnpin for Arg

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.