Struct rhai::FnPtr[][src]

pub struct FnPtr(_, _);
Expand description

A general function pointer, which may carry additional (i.e. curried) argument values to be passed onto a function during a call.

Implementations

impl FnPtr[src]

pub fn new(name: impl Into<Identifier>) -> Result<Self, Box<EvalAltResult>>[src]

Create a new function pointer.

pub fn fn_name(&self) -> &str[src]

Get the name of the function.

pub fn curry(&self) -> &[Dynamic][src]

Get the curried arguments.

pub fn add_curry(&mut self, value: Dynamic) -> &mut Self[src]

Add a new curried argument.

pub fn set_curry(
    &mut self,
    values: impl IntoIterator<Item = Dynamic>
) -> &mut Self
[src]

Set curried arguments to the function pointer.

pub fn is_curried(&self) -> bool[src]

Is the function pointer curried?

pub fn is_anonymous(&self) -> bool[src]

Does the function pointer refer to an anonymous function?

Not available under no_function.

pub fn call_dynamic(
    &self,
    ctx: &NativeCallContext<'_>,
    this_ptr: Option<&mut Dynamic>,
    arg_values: impl AsMut<[Dynamic]>
) -> Result<Dynamic, Box<EvalAltResult>>
[src]

Call the function pointer with curried arguments (if any).

If this function is a script-defined function, it must not be marked private.

WARNING

All the arguments are consumed, meaning that they’re replaced by (). This is to avoid unnecessarily cloning the arguments. Do not use the arguments after this call. If they are needed afterwards, clone them before calling this function.

Trait Implementations

impl Clone for FnPtr[src]

fn clone(&self) -> FnPtr[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for FnPtr[src]

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

Formats the value using the given formatter. Read more

impl Display for FnPtr[src]

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

Formats the value using the given formatter. Read more

impl From<FnPtr> for Dynamic[src]

fn from(value: FnPtr) -> Self[src]

Performs the conversion.

impl TryFrom<&'_ str> for FnPtr[src]

type Error = Box<EvalAltResult>

The type returned in the event of a conversion error.

fn try_from(value: &str) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<ImmutableString> for FnPtr[src]

type Error = Box<EvalAltResult>

The type returned in the event of a conversion error.

fn try_from(value: ImmutableString) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<SmartString<Compact>> for FnPtr[src]

type Error = Box<EvalAltResult>

The type returned in the event of a conversion error.

fn try_from(value: Identifier) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<String> for FnPtr[src]

type Error = Box<EvalAltResult>

The type returned in the event of a conversion error.

fn try_from(value: String) -> Result<Self, Self::Error>[src]

Performs the conversion.

Auto Trait Implementations

impl !RefUnwindSafe for FnPtr

impl !Send for FnPtr

impl !Sync for FnPtr

impl Unpin for FnPtr

impl !UnwindSafe for FnPtr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.