[][src]Enum glsp::Val

pub enum Val {
    Nil,
    Int(i32),
    Flo(f32),
    Char(char),
    Bool(bool),
    Sym(Sym),
    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>),
    RFn(Root<RFn>),
}

Any GameLisp value.

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

Variants

Nil
Int(i32)
Flo(f32)
Char(char)
Bool(bool)
Sym(Sym)
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>)
RFn(Root<RFn>)

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 and Eq comparisons between values - for example, using Rust's == operator. If those comparisons encounter a GameLisp error, they will panic.

impl Val[src]

pub fn downgrade(&self) -> GcVal[src]

Constructs a GcVal based on this Val.

impl Val[src]

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

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

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

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

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

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

This method is only present when the "serde" feature is enabled.

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

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

This method is only present when the "serde" feature is enabled.

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_arr(&self) -> bool[src]

pub fn unwrap_arr(self) -> Root<Arr>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_str(self) -> Root<Str>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_tab(self) -> Root<Tab>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_giter(self) -> Root<GIter>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_obj(self) -> Root<Obj>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_class(self) -> Root<Class>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_gfn(self) -> Root<GFn>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_coro(self) -> Root<Coro>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_rdata(self) -> Root<RData>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

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

pub fn unwrap_rfn(self) -> Root<RFn>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[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 Eq for Val[src]

impl FromElement<char> for Val[src]

impl FromVal for Val[src]

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

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

impl IntoElement<char> for Val[src]

impl<'a> IntoVal for &'a Val[src]

impl<'a> IntoVal for &'a mut Val[src]

impl IntoVal for Val[src]

impl PartialEq<Val> for Val[src]

impl PartialOrd<Val> for Val[src]

impl Serialize for Val[src]

impl Splay for Val[src]

Auto Trait Implementations

impl !RefUnwindSafe for Val[src]

impl !Send for Val[src]

impl !Sync for Val[src]

impl Unpin for Val[src]

impl !UnwindSafe for Val[src]

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: IntoVal
[src]

impl<T> IntoVal for T where
    T: StaticMarker, 
[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.