Trait const_gen::CompileConst[][src]

pub trait CompileConst {
    fn const_type() -> String;
fn const_val(&self) -> String; fn const_declaration(&self, name: &str) -> String { ... }
fn const_definition(_attrs: &str) -> String { ... } }

Trait which defines how a type should be represented as a constant

Required methods

fn const_type() -> String[src]

Get a string representation of a type. This must be implemented for each type. Types with generics may need to be able to access an instance of one of its generic members and call this function in order to properly represent the type. Note that this is not necessarily a representation of the ACTUAL type, but rather the type that should be used if this data is going to be represented as a compile-time constant.

fn const_val(&self) -> String[src]

Get a string representation of the current value in constant form. This method is where the real magic happens, but self.const_declaration() is likely the only one you need to call.

Loading content...

Provided methods

fn const_declaration(&self, name: &str) -> String[src]

Takes a string (a SCREAMING_SNAKE_CASE string is preferred) to use as a constant name, then calls self.const_type() and self.const_val() in order to generate a Rust compile-time constant declaration statement.

fn const_definition(_attrs: &str) -> String[src]

Return a const definition for this type. Attributes may be included, and must be formatted as the compiler would expect to see them (including the pound sign and square brackets "#[...]"). Always returns an empty string for types defined in the standard library. Typically this is easier to call instead through the const_definition! macro.

Loading content...

Implementations on Foreign Types

impl CompileConst for u8[src]

impl CompileConst for u16[src]

impl CompileConst for u32[src]

impl CompileConst for u64[src]

impl CompileConst for u128[src]

impl CompileConst for usize[src]

impl CompileConst for i8[src]

impl CompileConst for i16[src]

impl CompileConst for i32[src]

impl CompileConst for i64[src]

impl CompileConst for i128[src]

impl CompileConst for isize[src]

impl CompileConst for f32[src]

impl CompileConst for f64[src]

impl CompileConst for String[src]

impl CompileConst for &str[src]

impl CompileConst for str[src]

impl<T: CompileConst> CompileConst for Vec<T>[src]

impl<T: CompileConst> CompileConst for &[T][src]

impl<T: CompileConst> CompileConst for Box<T>[src]

impl<T: CompileConst + Clone> CompileConst for Cow<'_, T>[src]

impl<T: CompileConst> CompileConst for Rc<T>[src]

impl<T: CompileConst> CompileConst for Arc<T>[src]

impl<K: CompileConst, V: CompileConst> CompileConst for HashMap<K, V>[src]

impl<E: CompileConst> CompileConst for HashSet<E>[src]

impl CompileConst for ()[src]

impl<T: CompileConst, U: CompileConst> CompileConst for (T, U)[src]

impl<T, U, V> CompileConst for (T, U, V) where
    T: CompileConst,
    U: CompileConst,
    V: CompileConst
[src]

impl<T, U, V, W> CompileConst for (T, U, V, W) where
    T: CompileConst,
    U: CompileConst,
    V: CompileConst,
    W: CompileConst
[src]

impl<T, U, V, W, X> CompileConst for (T, U, V, W, X) where
    T: CompileConst,
    U: CompileConst,
    V: CompileConst,
    W: CompileConst,
    X: CompileConst
[src]

impl<T, U, V, W, X, Y> CompileConst for (T, U, V, W, X, Y) where
    T: CompileConst,
    U: CompileConst,
    V: CompileConst,
    W: CompileConst,
    X: CompileConst,
    Y: CompileConst
[src]

impl<T, U, V, W, X, Y, Z> CompileConst for (T, U, V, W, X, Y, Z) where
    T: CompileConst,
    U: CompileConst,
    V: CompileConst,
    W: CompileConst,
    X: CompileConst,
    Y: CompileConst,
    Z: CompileConst
[src]

Loading content...

Implementors

Loading content...