Skip to main content

Method

Struct Method 

Source
pub struct Method { /* private fields */ }
Expand description

Executable method declaration with argument and return-type checking.

Implementations§

Source§

impl Method

Source

pub fn new( core: Weak<dyn Core>, scope: Option<Weak<dyn Scope>>, method: MethodDef, ) -> Rc<Self>

Creates a method from its parsed definition.

Source

pub fn name(&self) -> &str

Source

pub fn return_type(&self) -> Option<&[String]>

Source

pub fn args(&self) -> &[(Vec<String>, String)]

Source

pub fn statements(&self) -> &[Statement]

Source

pub fn call( &self, env: Rc<dyn Env>, args: Vec<Rc<dyn Var>>, ) -> Result<Option<Rc<dyn Var>>, RiddleError>

Invokes the method in a fresh local environment.

The call validates argument count and type compatibility, executes all method statements, and checks the declared return type (if any).

Trait Implementations§

Source§

impl Debug for Method

Source§

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

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

impl Scope for Method

Source§

fn core(self: Rc<Self>) -> Rc<dyn Core>

Source§

fn scope(&self) -> Option<Rc<dyn Scope>>

Source§

fn get_field(&self, name: &str) -> Option<Rc<Field>>

Source§

fn get_method(&self, name: &str, classes: &[Rc<dyn Type>]) -> Option<Rc<Method>>

Source§

fn get_type(&self, name: &str) -> Option<Rc<dyn Type>>

Source§

fn get_predicate(&self, name: &str) -> Option<Rc<Predicate>>

Source§

fn as_class(self: Rc<Self>) -> Option<Rc<dyn Class>>

Auto Trait Implementations§

§

impl Freeze for Method

§

impl !RefUnwindSafe for Method

§

impl !Send for Method

§

impl !Sync for Method

§

impl Unpin for Method

§

impl UnsafeUnpin for Method

§

impl !UnwindSafe for Method

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> 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, 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.