pub struct Variant { /* private fields */ }Implementations§
Source§impl Variant
impl Variant
pub fn module(self, db: &dyn HirDatabase) -> Module
pub fn parent_enum(self, db: &dyn HirDatabase) -> Enum
pub fn constructor_ty(self, db: &dyn HirDatabase) -> Type<'_>
pub fn name(self, db: &dyn HirDatabase) -> Name
pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field>
pub fn kind(self, db: &dyn HirDatabase) -> StructKind
pub fn value(self, db: &dyn HirDatabase) -> Option<Expr>
pub fn eval(self, db: &dyn HirDatabase) -> Result<i128, ConstEvalError<'_>>
pub fn layout(&self, db: &dyn HirDatabase) -> Result<Layout, LayoutError>
pub fn is_unstable(self, db: &dyn HirDatabase) -> bool
pub fn instantiate_infer<'db>( self, infer_ctxt: &InferCtxt<'db>, ) -> InstantiatedVariant<'db>
Trait Implementations§
Source§impl From<&Variant> for DefWithBodyId
impl From<&Variant> for DefWithBodyId
Source§impl From<EnumVariantId> for Variant
impl From<EnumVariantId> for Variant
Source§fn from(id: EnumVariantId) -> Self
fn from(id: EnumVariantId) -> Self
Converts to this type from the input type.
Source§impl From<Variant> for DefWithBody
impl From<Variant> for DefWithBody
Source§fn from(it: Variant) -> DefWithBody
fn from(it: Variant) -> DefWithBody
Converts to this type from the input type.
Source§impl From<Variant> for EnumVariantId
impl From<Variant> for EnumVariantId
Source§impl From<Variant> for VariantDef
impl From<Variant> for VariantDef
Source§fn from(it: Variant) -> VariantDef
fn from(it: Variant) -> VariantDef
Converts to this type from the input type.
Source§impl HasAttrs for Variant
impl HasAttrs for Variant
fn attrs(self, db: &dyn HirDatabase) -> AttrsWithOwner
fn hir_docs(self, db: &dyn HirDatabase) -> Option<&Docs>
Source§impl HasSource for Variant
impl HasSource for Variant
type Ast = Variant
Source§fn source(self, db: &dyn HirDatabase) -> Option<InFile<Variant>>
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Variant>>
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 moreSource§impl HasVisibility for Variant
Variants inherit visibility from the parent enum.
impl HasVisibility for Variant
Variants inherit visibility from the parent enum.
fn visibility(&self, db: &dyn HirDatabase) -> Visibility
fn is_visible_from(&self, db: &dyn HirDatabase, module: Module) -> bool
Source§impl<'db> HirDisplay<'db> for Variant
impl<'db> HirDisplay<'db> for Variant
fn hir_fmt(&self, f: &mut HirFormatter<'_, 'db>) -> Result
Source§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,
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.Source§fn display<'a>(
&'a self,
db: &'db (dyn HirDatabase + 'static),
display_target: DisplayTarget,
) -> HirDisplayWrapper<'a, 'db, Self>where
Self: Sized,
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)Source§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,
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)Source§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,
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, enumSource§fn display_source_code<'a>(
&'a self,
db: &'db (dyn HirDatabase + 'static),
module_id: ModuleIdLt<'static>,
allow_opaque: bool,
) -> Result<String, DisplaySourceCodeError>
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)Source§fn display_test<'a>(
&'a self,
db: &'db (dyn HirDatabase + 'static),
display_target: DisplayTarget,
) -> HirDisplayWrapper<'a, 'db, Self>where
Self: Sized,
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 purposesSource§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,
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 functionsimpl Copy for Variant
impl Eq for Variant
impl StructuralPartialEq for Variant
Auto Trait Implementations§
impl Freeze for Variant
impl RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl UnwindSafe for Variant
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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