Skip to main content

Constructor

Struct Constructor 

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

Executable constructor declaration.

Implementations§

Source§

impl Constructor

Source

pub fn new( core: Weak<dyn Core>, scope: Option<Weak<dyn Scope>>, constructor: ConstructorDef, ) -> Self

Creates a constructor from its parsed definition.

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>

Creates a new object instance and runs constructor statements.

Trait Implementations§

Source§

impl Debug for Constructor

Source§

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

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

impl Scope for Constructor

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§

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.