Struct jlrs::value::symbol::Symbol[][src]

#[repr(transparent)]pub struct Symbol<'base>(_, _);

Symbols are used Julia to represent identifiers, :x represents the Symbol x. Things that can be accessed using a Symbol include submodules, functions, and globals. However, the methods that provide this functionality in jlrs can use strings instead.

This struct implements JuliaTypecheck and Cast. It can be used in combination with DataType::is and Value::is; if the check returns true the Value can be cast to Symbol:

julia.frame(2, |global, frame| {
    let symbol_func = Module::core(global).function("Symbol")?;
    let symbol_str = Value::new(frame, "+")?;
    let symbol_val = symbol_func.call1(frame, symbol_str)?.unwrap();
    assert!(symbol_val.is::<Symbol>());

    let symbol = symbol_val.cast::<Symbol>()?;
    assert!(Module::base(global).function(symbol).is_ok());
    Ok(())
}).unwrap();

Implementations

impl<'base> Symbol<'base>[src]

pub fn new<S: AsRef<str>>(global: Global<'base>, symbol: S) -> Self[src]

Convert the given string to a Symbol.

pub fn extend<'global>(self, _: Global<'global>) -> Symbol<'global>[src]

Extend the Symbol's lifetime. Symbols are not garbage collected, but a Symbol returned as a Value from a Julia function inherits the frame's lifetime when it's cast to a Symbol. Its lifetime can be safely extended from 'frame to 'global using this method.

pub fn hash(self) -> usize[src]

The hash of this Symbol.

pub fn left(self) -> Option<Symbol<'base>>[src]

Symbols are stored using an invasive binary tree, this returns the left branch of the current node.

pub fn right(self) -> Option<Symbol<'base>>[src]

Symbols are stored using an invasive binary tree, this returns the right branch of the current node.

pub fn as_value(self) -> Value<'base, 'static>[src]

Convert self to a Value.

pub fn as_string(self) -> String[src]

Convert self to a String.

Trait Implementations

impl<'frame, 'data> Cast<'frame, 'data> for Symbol<'frame>[src]

type Output = Self

impl<'base> Clone for Symbol<'base>[src]

impl<'base> Copy for Symbol<'base>[src]

impl<'scope> Debug for Symbol<'scope>[src]

impl<'base, S> From<(Global<'base>, S)> for Symbol<'base> where
    S: AsRef<str>, 
[src]

impl<'base> Into<String> for Symbol<'base>[src]

impl<'base> Into<Value<'base, 'static>> for Symbol<'base>[src]

impl<'frame> JuliaType for Symbol<'frame>[src]

impl<'frame> JuliaTypecheck for Symbol<'frame>[src]

impl<'s> TemporarySymbol for Symbol<'s>[src]

impl<'frame> ValidLayout for Symbol<'frame>[src]

Auto Trait Implementations

impl<'base> RefUnwindSafe for Symbol<'base>[src]

impl<'base> !Send for Symbol<'base>[src]

impl<'base> !Sync for Symbol<'base>[src]

impl<'base> Unpin for Symbol<'base>[src]

impl<'base> UnwindSafe for Symbol<'base>[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> 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.