pub enum ConstantExprKind {
Literal(ConstantLiteral),
Adt {
info: VariantInformations,
fields: Vec<ConstantFieldExpr>,
},
Array {
fields: Vec<ConstantExpr>,
},
Tuple {
fields: Vec<ConstantExpr>,
},
GlobalName {
id: GlobalIdent,
generics: Vec<GenericArg>,
trait_refs: Vec<ImplExpr>,
variant_information: Option<VariantInformations>,
},
TraitConst {
impl_expr: ImplExpr,
name: String,
},
Borrow(ConstantExpr),
RawBorrow {
mutability: Mutability,
arg: ConstantExpr,
},
Cast {
source: ConstantExpr,
},
ConstRef {
id: ParamConst,
},
FnPtr {
def_id: DefId,
generics: Vec<GenericArg>,
generics_impls: Vec<ImplExpr>,
method_impl: Option<ImplExpr>,
},
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
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>
}
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
Fields
§
generics: Vec<GenericArg>
Todo(String)
Implementations§
Trait Implementations§
source§impl Clone for ConstantExprKind
impl Clone for ConstantExprKind
source§fn clone(&self) -> ConstantExprKind
fn clone(&self) -> ConstantExprKind
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
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
The name of the generated JSON Schema. Read more
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$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,
Compares and returns the maximum of two values. Read more
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
Mutably borrows from an owned value. Read more
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
)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