Enum clippy_utils::consts::Constant[−][src]

pub enum Constant {
Show 13 variants Str(String), Binary(Lrc<[u8]>), Char(char), Int(u128), F32(f32), F64(f64), Bool(bool), Vec(Vec<Constant>), Repeat(Box<Constant>, u64), Tuple(Vec<Constant>), RawPtr(u128), Ref(Box<Constant>), Err(Symbol),
}
Expand description

A LitKind-like enum to fold constant Exprs into.

Variants

Str(String)

Tuple Fields

0: String

A String (e.g., “abc”).

Binary(Lrc<[u8]>)

Tuple Fields

0: Lrc<[u8]>

A binary string (e.g., b"abc").

Char(char)

Tuple Fields

0: char

A single char (e.g., 'a').

Int(u128)

Tuple Fields

0: u128

An integer’s bit representation.

F32(f32)

Tuple Fields

0: f32

An f32.

F64(f64)

Tuple Fields

0: f64

An f64.

Bool(bool)

Tuple Fields

0: bool

true or false.

Vec(Vec<Constant>)

Tuple Fields

An array of constants.

Repeat(Box<Constant>, u64)

Tuple Fields

1: u64

Also an array, but with only one constant, repeated N times.

Tuple(Vec<Constant>)

Tuple Fields

A tuple of constants.

RawPtr(u128)

Tuple Fields

0: u128

A raw pointer.

Ref(Box<Constant>)

Tuple Fields

A reference

Err(Symbol)

Tuple Fields

0: Symbol

A literal with syntax error.

Implementations

Returns the integer value or None if self or val_type is not integer type.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes

Size for each variant:

  • Str: 31 bytes
  • Binary: 23 bytes
  • Char: 7 bytes
  • Int: 23 bytes
  • F32: 7 bytes
  • F64: 15 bytes
  • Bool: 1 byte
  • Vec: 31 bytes
  • Repeat: 23 bytes
  • Tuple: 31 bytes
  • RawPtr: 23 bytes
  • Ref: 15 bytes
  • Err: 7 bytes