[][src]Enum glsp::Val

pub enum Val {
    Nil,
    Int(i32),
    Flo(f32),
    Char(char),
    Bool(bool),
    Sym(Sym),
    RFn(RFn),
    Arr(Root<Arr>),
    Str(Root<Str>),
    Tab(Root<Tab>),
    GIter(Root<GIter>),
    Obj(Root<Obj>),
    Class(Root<Class>),
    GFn(Root<GFn>),
    Coro(Root<Coro>),
    RData(Root<RData>),
}

Any GameLisp value.

Many functions in this crate provide automatic conversions to and from Val, using the FromVal and ToVal traits.

Variants

Nil
Int(i32)
Flo(f32)
Char(char)
Bool(bool)
Sym(Sym)
RFn(RFn)
Arr(Root<Arr>)
Str(Root<Str>)
Tab(Root<Tab>)
GIter(Root<GIter>)
Obj(Root<Obj>)
Class(Root<Class>)
GFn(Root<GFn>)
Coro(Root<Coro>)
RData(Root<RData>)

Implementations

impl Val[src]

pub fn is_nil(&self) -> bool[src]

pub fn is_truthy(&self) -> bool[src]

Returns true if the value is anything other than #n or #f.

pub fn is_falsy(&self) -> bool[src]

Returns true if the value is #n or #f.

pub fn is_num(&self) -> bool[src]

Returns true if the value belongs to the num abstract type (int or flo).

pub fn is_deque(&self) -> bool[src]

Returns true if the value belongs to the deque abstract type (arr or str).

pub fn is_callable(&self) -> bool[src]

Returns true if the value belongs to the callable abstract type (fn, rfn or class).

pub fn is_expander(&self) -> bool[src]

Returns true if the value belongs to the expander abstract type (fn or rfn).

pub fn is_iterable(&self) -> bool[src]

Returns true if the value belongs to the iterable abstract type (arr, str, tab, iter or coro).

pub fn shallow_clone(&self) -> Result<Val, GError>[src]

Creates a shallow copy of the value.

Equivalent to (clone val).

pub fn deep_clone(&self) -> Result<Val, GError>[src]

Recursively copies the value and all of its contents.

Equivalent to (deep-clone val).

pub fn freeze(&self)[src]

Makes the value immutable.

Equivalent to (freeze! val).

pub fn deep_freeze(&self)[src]

Makes the value and all of its contents immutable.

Equivalent to (deep-freeze! val).

impl Val[src]

pub fn num_eq(&self, other: &Val) -> Option<bool>[src]

Equivalent to (== self other).

pub fn same(&self, other: &Val) -> bool[src]

Equivalent to (same? self other).

pub fn keys_eqv(&self, other: &Val) -> bool[src]

Equivalent to (keys-eqv? self other).

pub fn try_eq(&self, other: &Val) -> Result<bool, GError>[src]

Equivalent to (eq? self other).

Note that, because this method may need to invoke an op-eq? method when both of its arguments are objects or RData, it can potentially fail.

The same is true for PartialEq comparisons between values using Rust's == operator. In that case, if an error occurs, the operator will panic.

impl Val[src]

pub fn check_representability(&self) -> Result<(), &'static str>[src]

Returns Ok if this value can be losslessly converted to text.

pub fn check_serializability(&self) -> Result<(), &'static str>[src]

Returns Ok if this value can be serialized and deserialized using Serde.

impl Val[src]

pub fn type_name(&self) -> &'static str[src]

Returns the name of this value's primitive type, such as "nil" or "fn".

pub fn a_type_name(&self) -> &'static str[src]

Returns the name of this value's primitive type, prefixed with the indefinite article, such as "an arr" or "a fn".

match val {
	Val::Int(_) => (),
	_ => bail!("expected an int, received {}", val.a_type_name())
}

impl Val[src]

pub fn is_int(&self) -> bool[src]

pub fn unwrap_int(self) -> i32[src]

pub fn is_flo(&self) -> bool[src]

pub fn unwrap_flo(self) -> f32[src]

pub fn is_char(&self) -> bool[src]

pub fn unwrap_char(self) -> char[src]

pub fn is_bool(&self) -> bool[src]

pub fn unwrap_bool(self) -> bool[src]

pub fn is_sym(&self) -> bool[src]

pub fn unwrap_sym(self) -> Sym[src]

pub fn is_rfn(&self) -> bool[src]

pub fn unwrap_rfn(self) -> RFn[src]

pub fn is_arr(&self) -> bool[src]

pub fn unwrap_arr(self) -> Root<Arr>[src]

pub fn is_str(&self) -> bool[src]

pub fn unwrap_str(self) -> Root<Str>[src]

pub fn is_tab(&self) -> bool[src]

pub fn unwrap_tab(self) -> Root<Tab>[src]

pub fn is_giter(&self) -> bool[src]

pub fn unwrap_giter(self) -> Root<GIter>[src]

pub fn is_obj(&self) -> bool[src]

pub fn unwrap_obj(self) -> Root<Obj>[src]

pub fn is_class(&self) -> bool[src]

pub fn unwrap_class(self) -> Root<Class>[src]

pub fn is_gfn(&self) -> bool[src]

pub fn unwrap_gfn(self) -> Root<GFn>[src]

pub fn is_coro(&self) -> bool[src]

pub fn unwrap_coro(self) -> Root<Coro>[src]

pub fn is_rdata(&self) -> bool[src]

pub fn unwrap_rdata(self) -> Root<RData>[src]

Trait Implementations

impl Clone for Val[src]

impl Debug for Val[src]

impl Default for Val[src]

impl<'de> Deserialize<'de> for Val[src]

impl Display for Val[src]

impl FromElement<char> for Val[src]

impl FromVal for Val[src]

impl<'_> IntoElement<char> for &'_ mut Val[src]

impl<'_> IntoElement<char> for &'_ Val[src]

impl IntoElement<char> for Val[src]

impl PartialEq<Val> for Val[src]

impl Serialize for Val[src]

impl Splay for Val[src]

impl ToVal for Val[src]

Auto Trait Implementations

impl !GSend for Val

impl !GStore for Val

impl !RefUnwindSafe for Val

impl !Send for Val

impl !Sync for Val

impl Unpin for Val

impl !UnwindSafe for Val

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T> FromElement<Slot> for T where
    T: FromVal
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoElement<Slot> for T where
    T: ToVal
[src]

impl<T> IntoResult for T where
    T: ToVal
[src]

impl<'a, T> MakeArg<'a> for T where
    T: FromVal + MakeTemp<Temp = Slot>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.