pub struct Function<'hir> {Show 17 fields
pub source: SourceId,
pub contract: Option<ContractId>,
pub span: Span,
pub name: Option<Ident>,
pub kind: FunctionKind,
pub visibility: Visibility,
pub state_mutability: StateMutability,
pub modifiers: &'hir [Modifier<'hir>],
pub marked_virtual: bool,
pub virtual_: bool,
pub override_: bool,
pub overrides: &'hir [ContractId],
pub parameters: &'hir [VariableId],
pub returns: &'hir [VariableId],
pub body: Option<Block<'hir>>,
pub body_span: Span,
pub gettee: Option<VariableId>,
}Expand description
A function.
Fields§
§source: SourceIdThe source this function is defined in.
contract: Option<ContractId>The contract this function is defined in, if any.
span: SpanThe function span.
name: Option<Ident>The function name.
Only None if this is a constructor, fallback, or receive function.
kind: FunctionKindThe function kind.
visibility: VisibilityThe visibility of the function.
state_mutability: StateMutabilityThe state mutability of the function.
modifiers: &'hir [Modifier<'hir>]Modifiers, or base classes if this is a constructor.
marked_virtual: boolWhether this function is marked with the virtual keyword.
virtual_: boolWhether this function is marked with the virtual keyword or is defined in an interface.
override_: boolWhether this function is marked with the override keyword.
overrides: &'hir [ContractId]§parameters: &'hir [VariableId]The function parameters.
returns: &'hir [VariableId]The function returns.
body: Option<Block<'hir>>The function body.
body_span: SpanThe function body span.
gettee: Option<VariableId>The variable this function is a getter of, if any.
Implementations§
Source§impl Function<'_>
impl Function<'_>
Sourcepub fn keyword_span(&self) -> Span
pub fn keyword_span(&self) -> Span
Returns the span of the kind keyword.
Sourcepub fn is_free(&self) -> bool
pub fn is_free(&self) -> bool
Returns true if this is a free function, meaning it is not part of a contract.
pub fn is_ordinary(&self) -> bool
pub fn is_part_of_external_interface(&self) -> bool
Sourcepub fn is_special(&self) -> bool
pub fn is_special(&self) -> bool
Returns true if this is a receive or fallback function
Sourcepub fn is_constructor(&self) -> bool
pub fn is_constructor(&self) -> bool
Returns true if this is a constructor
Sourcepub fn mutates_state(&self) -> bool
pub fn mutates_state(&self) -> bool
Returns true if this function mutates state
Sourcepub fn variables(&self) -> impl DoubleEndedIterator + Clone + use<'_>
pub fn variables(&self) -> impl DoubleEndedIterator + Clone + use<'_>
Returns an iterator over all variables in the function.
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Returns the description of the function.
Trait Implementations§
Auto Trait Implementations§
impl<'hir> Freeze for Function<'hir>
impl<'hir> RefUnwindSafe for Function<'hir>
impl<'hir> Send for Function<'hir>
impl<'hir> Sync for Function<'hir>
impl<'hir> Unpin for Function<'hir>
impl<'hir> UnwindSafe for Function<'hir>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more