Enum knightrs::Value[][src]

pub enum Value {
    Null,
    Boolean(Boolean),
    Number(Number),
    Text(Text),
    Variable(Variable),
    Function(FunctionRc<[Value]>),
}

Variants

Null
Boolean(Boolean)
Number(Number)
Text(Text)
Variable(Variable)
Function(FunctionRc<[Value]>)

Implementations

impl Value[src]

pub fn run(&self, env: &mut Environment<'_, '_, '_>) -> Result<Self, Error>[src]

#[must_use = "getting the type name by itself does nothing."]
pub const fn typename(&self) -> &'static str
[src]

pub fn to_boolean(&self) -> Result<Boolean, Error>[src]

pub fn to_number(&self) -> Result<Number, Error>[src]

pub fn to_text(&self) -> Result<Text, Error>[src]

impl Value[src]

pub fn parse_str<S: AsRef<str>>(
    input: S,
    env: &mut Environment<'_, '_, '_>
) -> Result<Self, ParseError>
[src]

Parses out a stream from the given input within the context of env.

This function simply calls [parse] with a char iterator over input; see it for more details.

Errors

This function returns any errors that [parse] returns.

pub fn parse<S: IntoIterator<Item = char>>(
    input: S,
    env: &mut Environment<'_, '_, '_>
) -> Result<Self, ParseError>
[src]

Parses out a stream from the given input within the context of env.

Note: Yes, technically this could be an iterator over u8, as the Knight specs clearly state that all source bytes are a subset of ASCII. However, we may want to support fun stuff like non-ASCII variables as an optional extension in the future. As such, char is required.

Errors

This function returns any errors that occur whilst parsing; See ParseError’s variants for what conditions can cause errors.

See Also

Section 1. within the Knight specs for parsing.

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl Default for Value[src]

impl Eq for Value[src]

impl From<Text> for Value[src]

impl From<Variable> for Value[src]

impl From<bool> for Value[src]

impl From<i64> for Value[src]

impl PartialEq<Value> for Value[src]

impl TryFrom<&'_ Value> for Boolean[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<&'_ Value> for Text[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<&'_ Value> for Number[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl !RefUnwindSafe for Value

impl !Send for Value

impl !Sync for Value

impl Unpin for Value

impl !UnwindSafe for Value

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> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,