[][src]Trait canrun::value::IntoVal

pub trait IntoVal<T: Debug> {
    fn into_val(self) -> Val<T>;
}

Helper for converting into Val<T>.

In order to be able to mix resolved values and logical variables in the same state, they need to be contained in the shared Val enum. This trait provides a standard way to convert various types of values into this container enum without manual wrapping.

TLDR: If you see a function that takes IntoVal<T>

fn foo<T: Debug, TV: IntoVal<T>>(bar: TV) -> Val<T> {
     bar.into_val()
}

That means it can take any of these types and will take care of converting them into a Val<T> for you:

let a: Val<i32> = foo(1); // a plain value of type `T`
let b: Val<i32> = foo(var()); // an `LVar<T>`
let c: Val<i32> = foo(a); // a `Val<T>`

Required methods

fn into_val(self) -> Val<T>

Convert various T related values into a Val<T>.

Example:

use canrun::{var, IntoVal, Val, LVar};

let x: LVar<i32> = var();
let x_val: Val<i32> = x.into_val();

let y: i32 = 1;
let y_val: Val<i32> = y.into_val();
Loading content...

Implementations on Foreign Types

impl<'_, T: Clone + Debug> IntoVal<T> for &'_ T[src]

Loading content...

Implementors

impl<'_, T: Debug> IntoVal<T> for &'_ Val<T>[src]

impl<'_, T: Debug> IntoVal<T> for &'_ LVar<T>[src]

impl<T: Debug> IntoVal<T> for Val<T>[src]

impl<T: Debug> IntoVal<T> for LVar<T>[src]

impl<T: Debug> IntoVal<T> for T[src]

Loading content...