pub enum ConstantExprKind {
Show 13 variants
Literal(ConstantLiteral),
Adt {
info: VariantInformations,
fields: Vec<ConstantFieldExpr>,
},
Array {
fields: Vec<ConstantExpr>,
},
Tuple {
fields: Vec<ConstantExpr>,
},
GlobalName(ItemRef),
TraitConst {
impl_expr: ImplExpr,
name: String,
},
Borrow(ConstantExpr),
RawBorrow {
mutability: Mutability,
arg: ConstantExpr,
},
Cast {
source: ConstantExpr,
},
ConstRef {
id: ParamConst,
},
FnPtr(ItemRef),
Memory(Vec<u8>),
Todo(String),
}
Expand description
The subset of Expr that corresponds to constants.
Variants§
Literal(ConstantLiteral)
Adt
Array
Fields
fields: Vec<ConstantExpr>
Tuple
Fields
fields: Vec<ConstantExpr>
GlobalName(ItemRef)
A top-level constant or a constant appearing in an impl block.
Remark: constants can have generic parameters. Example:
struct V<const N: usize, T> {
x: [T; N],
}
impl<const N: usize, T> V<N, T> {
const LEN: usize = N; // This has generics <N, T>
}
If options.inline_anon_consts
is false
, this is also used for inline const blocks and
advanced const generics expressions.
TraitConst
A trait constant
Ex.:
impl Foo for Bar {
const C : usize = 32; // <-
}
Borrow(ConstantExpr)
A shared reference to a static variable.
RawBorrow
A raw borrow (*const
or *mut
).
Cast
A cast <source> as <type>
, <type>
is stored as the type of
the current constant expression. Currently, this is only used
to represent lit as *mut T
or lit as *const T
, where lit
is a usize
literal.
Fields
source: ConstantExpr
ConstRef
Fields
id: ParamConst
FnPtr(ItemRef)
Memory(Vec<u8>)
A blob of memory containing the byte representation of the value. This can occur when evaluating MIR constants. Interpreting this back to a structured value is left as an exercice to the consumer.
Todo(String)
Implementations§
Trait Implementations§
Source§impl Clone for ConstantExprKind
impl Clone for ConstantExprKind
Source§fn clone(&self) -> ConstantExprKind
fn clone(&self) -> ConstantExprKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ConstantExprKind
impl Debug for ConstantExprKind
Source§impl<'de> Deserialize<'de> for ConstantExprKind
impl<'de> Deserialize<'de> for ConstantExprKind
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for ConstantExprKind
impl Hash for ConstantExprKind
Source§impl JsonSchema for ConstantExprKind
impl JsonSchema for ConstantExprKind
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl Ord for ConstantExprKind
impl Ord for ConstantExprKind
Source§fn cmp(&self, other: &ConstantExprKind) -> Ordering
fn cmp(&self, other: &ConstantExprKind) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ConstantExprKind
impl PartialEq for ConstantExprKind
Source§impl PartialOrd for ConstantExprKind
impl PartialOrd for ConstantExprKind
Source§impl Serialize for ConstantExprKind
impl Serialize for ConstantExprKind
impl Eq for ConstantExprKind
impl StructuralPartialEq for ConstantExprKind
Auto Trait Implementations§
impl Freeze for ConstantExprKind
impl RefUnwindSafe for ConstantExprKind
impl Send for ConstantExprKind
impl Sync for ConstantExprKind
impl Unpin for ConstantExprKind
impl UnwindSafe for ConstantExprKind
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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