pub struct Function { /* private fields */ }
Implementations§
source§impl Function
impl Function
pub fn module(self, db: &dyn HirDatabase) -> Module
pub fn name(self, db: &dyn HirDatabase) -> Name
pub fn ty(self, db: &dyn HirDatabase) -> Type
pub fn fn_ptr_type(self, db: &dyn HirDatabase) -> Type
sourcepub fn ret_type(self, db: &dyn HirDatabase) -> Type
pub fn ret_type(self, db: &dyn HirDatabase) -> Type
Get this function’s return type
pub fn ret_type_with_args( self, db: &dyn HirDatabase, generics: impl Iterator<Item = Type>, ) -> Type
pub fn async_ret_type(self, db: &dyn HirDatabase) -> Option<Type>
pub fn has_self_param(self, db: &dyn HirDatabase) -> bool
pub fn self_param(self, db: &dyn HirDatabase) -> Option<SelfParam>
pub fn assoc_fn_params(self, db: &dyn HirDatabase) -> Vec<Param>
pub fn num_params(self, db: &dyn HirDatabase) -> usize
pub fn method_params(self, db: &dyn HirDatabase) -> Option<Vec<Param>>
pub fn params_without_self(self, db: &dyn HirDatabase) -> Vec<Param>
pub fn params_without_self_with_args( self, db: &dyn HirDatabase, generics: impl Iterator<Item = Type>, ) -> Vec<Param>
pub fn is_const(self, db: &dyn HirDatabase) -> bool
pub fn is_async(self, db: &dyn HirDatabase) -> bool
pub fn returns_impl_future(self, db: &dyn HirDatabase) -> bool
sourcepub fn is_test(self, db: &dyn HirDatabase) -> bool
pub fn is_test(self, db: &dyn HirDatabase) -> bool
Does this function have #[test]
attribute?
sourcepub fn is_main(self, db: &dyn HirDatabase) -> bool
pub fn is_main(self, db: &dyn HirDatabase) -> bool
is this a fn main
or a function with an export_name
of main
?
sourcepub fn exported_main(self, db: &dyn HirDatabase) -> bool
pub fn exported_main(self, db: &dyn HirDatabase) -> bool
Is this a function with an export_name
of main
?
sourcepub fn is_ignore(self, db: &dyn HirDatabase) -> bool
pub fn is_ignore(self, db: &dyn HirDatabase) -> bool
Does this function have the ignore attribute?
sourcepub fn is_bench(self, db: &dyn HirDatabase) -> bool
pub fn is_bench(self, db: &dyn HirDatabase) -> bool
Does this function have #[bench]
attribute?
sourcepub fn is_unstable(self, db: &dyn HirDatabase) -> bool
pub fn is_unstable(self, db: &dyn HirDatabase) -> bool
Is this function marked as unstable with #[feature]
attribute?
pub fn is_unsafe_to_call(self, db: &dyn HirDatabase) -> bool
sourcepub fn has_body(self, db: &dyn HirDatabase) -> bool
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.
pub fn as_proc_macro(self, db: &dyn HirDatabase) -> Option<Macro>
pub fn eval( self, db: &dyn HirDatabase, span_formatter: impl Fn(FileId, TextRange) -> String, ) -> Result<String, ConstEvalError>
Trait Implementations§
source§impl AsAssocItem for Function
impl AsAssocItem for Function
fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem>
source§impl AsExternAssocItem for Function
impl AsExternAssocItem for Function
fn as_extern_assoc_item(self, db: &dyn HirDatabase) -> Option<ExternAssocItem>
source§impl From<Function> for DefWithBody
impl From<Function> for DefWithBody
source§fn from(it: Function) -> DefWithBody
fn from(it: Function) -> DefWithBody
Converts to this type from the input type.
source§impl From<Function> for GenericDef
impl From<Function> for GenericDef
source§fn from(it: Function) -> GenericDef
fn from(it: Function) -> GenericDef
Converts to this type from the input type.
source§impl HasAttrs for Function
impl HasAttrs for Function
fn attrs(self, db: &dyn HirDatabase) -> AttrsWithOwner
source§impl HasContainer for Function
impl HasContainer for Function
fn container(&self, db: &dyn HirDatabase) -> ItemContainer
source§impl HasVisibility for Function
impl HasVisibility for Function
fn visibility(&self, db: &dyn HirDatabase) -> Visibility
fn is_visible_from(&self, db: &dyn HirDatabase, module: Module) -> bool
source§impl HirDisplay for Function
impl HirDisplay for Function
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
§fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a
Display
able type that is human-readable.§fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a
Display
able type that is human-readable.
Use this for showing types to the user (e.g. diagnostics)§fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a
Display
able 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: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_limited<'a>(
&'a self,
db: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a
Display
able 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: &'a dyn HirDatabase,
module_id: ModuleId,
allow_opaque: bool,
) -> Result<String, DisplaySourceCodeError>
fn display_source_code<'a>( &'a self, db: &'a dyn HirDatabase, module_id: ModuleId, 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: &'a dyn HirDatabase,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a String representation of
self
for test purposes§fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a String representation of
self
that shows the constraint from
the container for functionsimpl Copy for Function
impl Eq for Function
impl StructuralPartialEq for Function
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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
Mutably borrows from an owned value. Read more
§impl<T> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
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
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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 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>
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