Struct jlrs::value::symbol::Symbol [−][src]
Symbol
s 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. Symbol
s 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]
Symbol
s are stored using an invasive binary tree, this returns the left branch of the
current node.
pub fn right(self) -> Option<Symbol<'base>>
[src]
Symbol
s 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
fn cast(value: Value<'frame, 'data>) -> JlrsResult<Self::Output>
[src]
unsafe fn cast_unchecked(value: Value<'frame, 'data>) -> Self::Output
[src]
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]
S: AsRef<str>,
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]
unsafe fn julia_type() -> *mut jl_datatype_t
[src]
impl<'frame> JuliaTypecheck for Symbol<'frame>
[src]
unsafe fn julia_typecheck(t: DataType<'_>) -> bool
[src]
impl<'s> TemporarySymbol for Symbol<'s>
[src]
impl<'frame> ValidLayout for Symbol<'frame>
[src]
unsafe fn valid_layout(v: Value<'_, '_>) -> bool
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,