Struct ink_ir::Constructor

source ·
pub struct Constructor { /* private fields */ }
Expand description

An ink! constructor definition.

§Example

§Inherent implementation constructor:

impl MyStorage {
    #[ink(constructor)]
    pub fn new(init_value: i32) -> Self {
        /* contract initialization goes here */
    }
}

§Trait implementation constructor:

impl MyTrait for MyStorage {
    #[ink(constructor)]
    fn new(init_value: i32) -> Self {
        // contract initialization goes here
    }
}

Implementations§

source§

impl Constructor

source

pub fn attrs(&self) -> &[Attribute]

Returns a slice of all non-ink! attributes of the ink! constructor.

source

pub fn get_cfg_attrs(&self, span: Span) -> Vec<TokenStream>

Returns a list of cfg attributes if any.

source

pub fn output(&self) -> Option<&Type>

Returns the return type of the ink! constructor if any.

Trait Implementations§

source§

impl Callable for Constructor

source§

fn kind(&self) -> CallableKind

Returns the kind of the ink! callable.
source§

fn ident(&self) -> &Ident

Returns the identifier of the ink! callable.
source§

fn user_provided_selector(&self) -> Option<&Selector>

Returns the selector of the ink! callable if any has been manually set.
source§

fn has_wildcard_selector(&self) -> bool

Returns true if the ink! callable is flagged as a wildcard selector.
source§

fn has_wildcard_complement_selector(&self) -> bool

Returns true if the ink! callable is flagged as a wildcard complement selector.
source§

fn is_payable(&self) -> bool

Returns true if the ink! callable is flagged as payable. Read more
source§

fn is_default(&self) -> bool

Returns true if the ink! callable is flagged as default. Read more
source§

fn visibility(&self) -> Visibility

Returns the visibility of the ink! callable.
source§

fn inputs(&self) -> InputsIter<'_>

Returns an iterator yielding all input parameters of the ink! callable.
source§

fn inputs_span(&self) -> Span

Returns the span of the inputs of the ink! callable.
source§

fn statements(&self) -> &[Stmt]

Returns a slice over shared references to the statements of the callable.
source§

impl Debug for Constructor

source§

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

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

impl<'a> From<&'a Constructor> for InputsIter<'a>

source§

fn from(constructor: &'a Constructor) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Constructor

source§

fn eq(&self, other: &Constructor) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToTokens for Constructor

source§

fn to_tokens(&self, tokens: &mut TokenStream)

We mainly implement this trait for this ink! type to have a derived Spanned implementation for it.

source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more
source§

impl TryFrom<ImplItemFn> for Constructor

§

type Error = Error

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

fn try_from(method_item: ImplItemFn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Constructor

source§

impl StructuralPartialEq for Constructor

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> Spanned for T
where T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
source§

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

§

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

§

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.