pub enum ConstValue {
Show 13 variants
Integer(i64),
Bool(bool),
Type(Type),
Unit,
Struct(u32),
Array(u32),
ComptimeStr(u32),
EnumVariant {
enum_id: EnumId,
variant_idx: u32,
},
EnumData {
enum_id: EnumId,
variant_idx: u32,
heap_idx: u32,
},
EnumStruct {
enum_id: EnumId,
variant_idx: u32,
heap_idx: u32,
},
BreakSignal,
ContinueSignal,
ReturnSignal,
}Expand description
A value that can be computed at compile time.
This is used for constant expression evaluation, primarily for compile-time
bounds checking. It can be extended for future comptime features.
Variants§
Integer(i64)
Integer value (signed to handle arithmetic correctly)
Bool(bool)
Boolean value
Type(Type)
Type value - stores a concrete type for type parameters.
This is used when a comptime T: type parameter is instantiated
with a specific type like i32 or bool.
Unit
Unit value () — the result of statements (let bindings, assignments)
and expressions of unit type within comptime blocks.
Struct(u32)
Index into Sema::comptime_heap for a comptime struct instance.
Preserves the Copy trait while supporting composite values.
Array(u32)
Index into Sema::comptime_heap for a comptime array instance.
ComptimeStr(u32)
Index into Sema::comptime_heap for a comptime string value.
EnumVariant
Enum variant with no data (e.g., Color::Red).
Stores the enum id and variant index.
EnumData
Enum variant with tuple data (e.g., Option::Some(42)).
Data fields are stored on the comptime heap.
EnumStruct
Enum variant with struct data (e.g., Shape::Rect { w: 10, h: 20 }).
Fields are stored on the comptime heap in declaration order.
BreakSignal
Internal control-flow signal: produced by break inside a comptime loop.
Never escapes evaluate_comptime_block — consumed by Loop/InfiniteLoop cases.
ContinueSignal
Internal control-flow signal: produced by continue inside a comptime loop.
Never escapes evaluate_comptime_block — consumed by Loop/InfiniteLoop cases.
ReturnSignal
Internal control-flow signal: produced by return inside a comptime function.
Never escapes a comptime Call handler — the return value is stored in
Sema::comptime_return_value before this signal is returned.
Implementations§
Trait Implementations§
Source§impl Clone for ConstValue
impl Clone for ConstValue
Source§fn clone(&self) -> ConstValue
fn clone(&self) -> ConstValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConstValue
impl Debug for ConstValue
Source§impl PartialEq for ConstValue
impl PartialEq for ConstValue
impl Copy for ConstValue
impl Eq for ConstValue
impl StructuralPartialEq for ConstValue
Auto Trait Implementations§
impl Freeze for ConstValue
impl RefUnwindSafe for ConstValue
impl Send for ConstValue
impl Sync for ConstValue
impl Unpin for ConstValue
impl UnwindSafe for ConstValue
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,
§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
§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
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>
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].