Enum clippy::consts::Constant [] [src]

pub enum Constant {
    Str(String, StrStyle),
    Binary(Rc<Vec<u8>>),
    Byte(u8),
    Char(char),
    Int(u64, LitIntType, Sign),
    Float(String, FloatWidth),
    Bool(bool),
    Vec(Vec<Constant>),
    Repeat(Box<Constant>, usize),
    Tuple(Vec<Constant>),
}

a Lit_-like enum to fold constant Exprs into

Variants

Str

a String "abc"

Binary

a Binary String b"abc"

Byte

a single byte b'a'

Char

a single char 'a'

Int

an integer, third argument is whether the value is negated

Float

a float with given type

Bool

true or false

Vec

an array of constants

Repeat

also an array, but with only one constant, repeated N times

Tuple

a tuple of constants

Methods

impl Constant

fn as_float(&self) -> Option<f64>

convert this constant to a f64, if possible

Trait Implementations

impl PartialEq for Constant

fn eq(&self, other: &Constant) -> bool

1.0.0fn ne(&self, other: &Rhs) -> bool

impl Hash for Constant

fn hash<H>(&self, state: &mut H) where H: Hasher

1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl PartialOrd for Constant

fn partial_cmp(&self, other: &Constant) -> Option<Ordering>

1.0.0fn lt(&self, other: &Rhs) -> bool

1.0.0fn le(&self, other: &Rhs) -> bool

1.0.0fn gt(&self, other: &Rhs) -> bool

1.0.0fn ge(&self, other: &Rhs) -> bool

Derived Implementations

impl Clone for Constant

fn clone(&self) -> Constant

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for Constant

fn fmt(&self, __arg_0: &mut Formatter) -> Result