pub struct Type { /* private fields */ }
Implementations§
source§impl Type
impl Type
pub fn reference(inner: &Type, m: Mutability) -> Type
pub fn new_slice(ty: Type) -> Type
pub fn is_unit(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_never(&self) -> bool
pub fn is_mutable_reference(&self) -> bool
pub fn is_reference(&self) -> bool
pub fn as_reference(&self) -> Option<(Type, Mutability)>
pub fn is_slice(&self) -> bool
pub fn is_usize(&self) -> bool
pub fn is_int_or_uint(&self) -> bool
pub fn remove_ref(&self) -> Option<Type>
pub fn strip_references(&self) -> Type
pub fn strip_reference(&self) -> Type
pub fn is_unknown(&self) -> bool
sourcepub fn impls_into_future(&self, db: &dyn HirDatabase) -> bool
pub fn impls_into_future(&self, db: &dyn HirDatabase) -> bool
Checks that particular type ty
implements std::future::IntoFuture
or
std::future::Future
.
This function is used in .await
syntax completion.
sourcepub fn impls_fnonce(&self, db: &dyn HirDatabase) -> bool
pub fn impls_fnonce(&self, db: &dyn HirDatabase) -> bool
Checks that particular type ty
implements std::ops::FnOnce
.
This function can be used to check if a particular type is callable, since FnOnce is a supertrait of Fn and FnMut, so all callable types implements at least FnOnce.
pub fn impls_trait(
&self,
db: &dyn HirDatabase,
trait_: Trait,
args: &[Type]
) -> bool
pub fn normalize_trait_assoc_type(
&self,
db: &dyn HirDatabase,
args: &[Type],
alias: TypeAlias
) -> Option<Type>
pub fn is_copy(&self, db: &dyn HirDatabase) -> bool
pub fn as_callable(&self, db: &dyn HirDatabase) -> Option<Callable>
pub fn is_closure(&self) -> bool
pub fn is_fn(&self) -> bool
pub fn is_array(&self) -> bool
pub fn is_packed(&self, db: &dyn HirDatabase) -> bool
pub fn is_raw_ptr(&self) -> bool
pub fn contains_unknown(&self) -> bool
pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)>
pub fn tuple_fields(&self, _db: &dyn HirDatabase) -> Vec<Type>
pub fn autoderef<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> impl Iterator<Item = Type> + 'a
pub fn iterate_assoc_items<T>(
&self,
db: &dyn HirDatabase,
krate: Crate,
callback: impl FnMut(AssocItem) -> Option<T>
) -> Option<T>
pub fn type_arguments(&self) -> impl Iterator<Item = Type> + '_
pub fn iterate_method_candidates<T>(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
callback: impl FnMut(Function) -> Option<T>
) -> Option<T>
pub fn iterate_path_candidates<T>(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
callback: impl FnMut(AssocItem) -> Option<T>
) -> Option<T>
pub fn as_adt(&self) -> Option<Adt>
pub fn as_builtin(&self) -> Option<BuiltinType>
pub fn as_dyn_trait(&self) -> Option<Trait>
sourcepub fn applicable_inherent_traits<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> impl Iterator<Item = Trait> + 'a
pub fn applicable_inherent_traits<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> impl Iterator<Item = Trait> + 'a
If a type can be represented as dyn Trait
, returns all traits accessible via this type,
or an empty iterator otherwise.
pub fn env_traits<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> impl Iterator<Item = Trait> + 'a
pub fn as_impl_traits(
&self,
db: &dyn HirDatabase
) -> Option<impl Iterator<Item = Trait>>
pub fn as_associated_type_parent_trait(
&self,
db: &dyn HirDatabase
) -> Option<Trait>
pub fn walk(&self, db: &dyn HirDatabase, cb: impl FnMut(Type))
pub fn could_unify_with(&self, db: &dyn HirDatabase, other: &Type) -> bool
pub fn could_coerce_to(&self, db: &dyn HirDatabase, to: &Type) -> bool
pub fn as_type_param(&self, db: &dyn HirDatabase) -> Option<TypeParam>
Trait Implementations§
source§impl HirDisplay for Type
impl HirDisplay for Type
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
source§fn into_displayable<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn into_displayable<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a
Display
able type that is human-readable.source§fn display<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a)
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a)
) -> 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)source§fn display_truncated<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
max_size: Option<usize>
) -> 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)source§fn display_source_code<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
fn display_source_code<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a),
module_id: ModuleId
) -> 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)source§fn display_test<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a)
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_test<'a>(
&'a self,
db: &'a (dyn HirDatabase + 'a)
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Returns a String representation of
self
for test purposessource§impl PartialEq<Type> for Type
impl PartialEq<Type> for Type
impl Eq for Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations§
§impl<T> Cast for T
impl<T> Cast for T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.