Function

Struct Function 

Source
pub struct Function {
    pub(crate) id: AnyFunctionId,
}

Fields§

§id: AnyFunctionId

Implementations§

Source§

impl Function

Source

pub fn module(self, db: &dyn HirDatabase) -> Module

Source

pub fn name(self, db: &dyn HirDatabase) -> Name

Source

pub fn ty(self, db: &dyn HirDatabase) -> Type<'_>

Source

pub fn fn_ptr_type(self, db: &dyn HirDatabase) -> Type<'_>

Source

pub(crate) fn fn_sig<'db>( self, db: &'db dyn HirDatabase, ) -> (ParamEnvAndCrate<'db>, PolyFnSig<'db>)

Source

pub fn ret_type(self, db: &dyn HirDatabase) -> Type<'_>

Get this function’s return type

Source

pub fn ret_type_with_args<'db>( self, db: &'db dyn HirDatabase, generics: impl Iterator<Item = Type<'db>>, ) -> Type<'db>

Source

pub(crate) fn adapt_generic_args<'db>( self, interner: DbInterner<'db>, generics: impl Iterator<Item = Type<'db>>, ) -> GenericArgs<'db>

Source

pub fn async_ret_type<'db>(self, db: &'db dyn HirDatabase) -> Option<Type<'db>>

Source

pub fn has_self_param(self, db: &dyn HirDatabase) -> bool

Source

pub fn self_param(self, db: &dyn HirDatabase) -> Option<SelfParam>

Source

pub fn assoc_fn_params(self, db: &dyn HirDatabase) -> Vec<Param<'_>>

Source

pub fn num_params(self, db: &dyn HirDatabase) -> usize

Source

pub fn method_params(self, db: &dyn HirDatabase) -> Option<Vec<Param<'_>>>

Source

pub fn params_without_self(self, db: &dyn HirDatabase) -> Vec<Param<'_>>

Source

pub fn params_without_self_with_args<'db>( self, db: &'db dyn HirDatabase, generics: impl Iterator<Item = Type<'db>>, ) -> Vec<Param<'db>>

Source

pub fn is_const(self, db: &dyn HirDatabase) -> bool

Source

pub fn is_async(self, db: &dyn HirDatabase) -> bool

Source

pub fn is_varargs(self, db: &dyn HirDatabase) -> bool

Source

pub fn extern_block(self, db: &dyn HirDatabase) -> Option<ExternBlock>

Source

pub fn returns_impl_future(self, db: &dyn HirDatabase) -> bool

Source

pub fn is_test(self, db: &dyn HirDatabase) -> bool

Does this function have #[test] attribute?

Source

pub fn is_main(self, db: &dyn HirDatabase) -> bool

is this a fn main or a function with an export_name of main?

Source

pub(crate) fn attrs(self, db: &dyn HirDatabase) -> AttrFlags

Source

pub fn exported_main(self, db: &dyn HirDatabase) -> bool

Is this a function with an export_name of main?

Source

pub fn is_ignore(self, db: &dyn HirDatabase) -> bool

Does this function have the ignore attribute?

Source

pub fn is_bench(self, db: &dyn HirDatabase) -> bool

Does this function have #[bench] attribute?

Source

pub fn is_unstable(self, db: &dyn HirDatabase) -> bool

Is this function marked as unstable with #[feature] attribute?

Source

pub fn is_unsafe_to_call( self, db: &dyn HirDatabase, caller: Option<Function>, call_edition: Edition, ) -> bool

Source

pub fn has_body(self, db: &dyn HirDatabase) -> bool

Whether this function declaration has a definition.

This is false in the case of required (not provided) trait methods.

Source

pub fn as_proc_macro(self, db: &dyn HirDatabase) -> Option<Macro>

Source

pub fn eval( self, db: &dyn HirDatabase, span_formatter: impl Fn(FileId, TextRange) -> String, ) -> Result<String, ConstEvalError>

Trait Implementations§

Source§

impl AsAssocItem for Function

Source§

impl AsExternAssocItem for Function

Source§

impl Clone for Function

Source§

fn clone(&self) -> Function

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Function

Source§

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

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

impl From<AnyFunctionId> for Function

Source§

fn from(id: AnyFunctionId) -> Function

Converts to this type from the input type.
Source§

impl From<Function> for AnyFunctionId

Source§

fn from(ty: Function) -> AnyFunctionId

Converts to this type from the input type.
Source§

impl From<Function> for DefWithBody

Source§

fn from(it: Function) -> DefWithBody

Converts to this type from the input type.
Source§

impl From<Function> for GenericDef

Source§

fn from(it: Function) -> GenericDef

Converts to this type from the input type.
Source§

impl From<Function> for ModuleDef

Source§

fn from(it: Function) -> ModuleDef

Converts to this type from the input type.
Source§

impl From<FunctionId> for Function

Source§

fn from(value: FunctionId) -> Self

Converts to this type from the input type.
Source§

impl HasAttrs for Function

Source§

fn attrs(self, db: &dyn HirDatabase) -> AttrsWithOwner

Source§

fn hir_docs(self, db: &dyn HirDatabase) -> Option<&Docs>

Source§

impl HasContainer for Function

Source§

impl HasCrate for Function

Source§

fn krate(&self, db: &dyn HirDatabase) -> Crate

Source§

impl HasName for Function

Source§

fn name(&self, db: &dyn HirDatabase) -> Option<Name>

Source§

impl HasSource for Function

Source§

type Ast = Fn

Source§

fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>>

Fetches the definition’s source node. Using crate::SemanticsImpl::source is preferred when working with crate::Semantics, as that caches the parsed file in the semantics’ cache. Read more
Source§

fn source_with_range( self, db: &dyn HirDatabase, ) -> Option<InFile<(TextRange, Option<Self::Ast>)>>

Fetches the source node, along with its full range. Read more
Source§

impl HasVisibility for Function

Source§

fn visibility(&self, db: &dyn HirDatabase) -> Visibility

Source§

fn is_visible_from(&self, db: &dyn HirDatabase, module: Module) -> bool

Source§

impl Hash for Function

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'db> HirDisplay<'db> for Function

Source§

fn hir_fmt(&self, f: &mut HirFormatter<'_, 'db>) -> Result

§

fn into_displayable<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), max_size: Option<usize>, limited_size: Option<usize>, omit_verbose_types: bool, display_target: DisplayTarget, display_kind: DisplayKind, closure_style: ClosureStyle, show_container_bounds: bool, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a Displayable type that is human-readable.
§

fn display<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a Displayable type that is human-readable. Use this for showing types to the user (e.g. diagnostics)
§

fn display_truncated<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), max_size: Option<usize>, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a Displayable type that is human-readable and tries to be succinct. Use this for showing types to the user where space is constrained (e.g. doc popups)
§

fn display_limited<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), limited_size: Option<usize>, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a Displayable type that is human-readable and tries to limit the number of items inside. Use this for showing definitions which may contain too many items, like trait, struct, enum
§

fn display_source_code<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), module_id: ModuleIdLt<'static>, allow_opaque: bool, ) -> Result<String, DisplaySourceCodeError>

Returns a String representation of self that can be inserted into the given module. Use this when generating code (e.g. assists)
§

fn display_test<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a String representation of self for test purposes
§

fn display_with_container_bounds<'a>( &'a self, db: &'db (dyn HirDatabase + 'static), show_container_bounds: bool, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, 'db, Self>
where Self: Sized,

Returns a String representation of self that shows the constraint from the container for functions
Source§

impl PartialEq for Function

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Function> for FunctionId

Source§

type Error = ()

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

fn try_from(v: Function) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Function

Source§

impl Eq for Function

Source§

impl StructuralPartialEq for Function

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,