#[non_exhaustive]pub enum ConstValue {
Boolean(bool),
Integer(i128),
Float {
mantissa: String,
exponent: Option<String>,
},
Fixed {
digits: String,
scale: u8,
},
Char(char),
WChar(u32),
String(String),
WString(Vec<u32>),
}Expand description
A constant expression’s value, in the form the expression had.
Ast::eval_integral answers for the constants that are numbers a
wire format cares about, and returns EvalError::NotIntegral for the
rest. That is the right answer where an integer is required — an array
bound, a @bit_bound, a case label — and the wrong one where the
question is only “what does this constant say”: const string MODULE_ID = "spatial.sensing.lidar/1.5"; is a perfectly evaluated
constant that no integer represents, and a backend that asked the
integral question could not emit it at all.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Boolean(bool)
TRUE / FALSE.
Integer(i128)
An integer, including a character or an enumerator evaluated as one, and every arithmetic expression over them.
Float
A floating-point literal, in the two halves it was written in.
Kept as text: the decimal a source wrote and the nearest f64 are
two different values, and which one a backend needs is the
backend’s business.
Fields
Fixed
A fixed-point literal — a decimal, and never a binary float.
Char(char)
A narrow character.
WChar(u32)
A wide character, as a code point.
String(String)
A narrow string, with escapes resolved.
WString(Vec<u32>)
A wide string, as code points.