Trait repr::FromTy [−][src]
pub trait FromTy<T> {
fn from_ty() -> Self;
}
Expand description
FromTy is a utility trait for ScalarType that defines a mapping between a Rust type T and its runtime representation as a ScalarType. Not all ScalarType variants have a 1-1 mapping to a Rust type but for those variants can simply be ignored.
The main usecase of FromTy is to use rustc’s inference to lift type information from compile
time to runtime, a primitive form of reflection. See the implementation of the fn_unary
macro
in expr
for an example use of this trait.