pub struct Binding(/* private fields */);
👎Deprecated since 0.6.0: Please use
Value
instead.Expand description
Implementations§
source§impl Binding
impl Binding
sourcepub fn new() -> Self
👎Deprecated since 0.2.0: this will no longer function as of Ruby 3.2Available on ruby_lte_3_1
only.
pub fn new() -> Self
ruby_lte_3_1
only.sourcepub fn from_value(val: Value) -> Option<Self>
👎Deprecated since 0.6.0
pub fn from_value(val: Value) -> Option<Self>
Return Some(Binding)
if val
is a Binding
, None
otherwise.
sourcepub fn eval<T, U>(self, s: T) -> Result<U, Error>where
T: IntoRString,
U: TryConvert,
👎Deprecated since 0.6.0: Please use value.funcall("eval", (s,))
instead.
pub fn eval<T, U>(self, s: T) -> Result<U, Error>where
T: IntoRString,
U: TryConvert,
value.funcall("eval", (s,))
instead.Evaluate a string of Ruby code within the binding’s context.
§Examples
use magnus::{eval, Binding};
let binding = eval::<Binding>("binding").unwrap();
assert_eq!(binding.eval::<_, i64>("1 + 2").unwrap(), 3);
sourcepub fn local_variable_get<N, T>(self, name: N) -> Result<T, Error>where
N: IntoSymbol,
T: TryConvert,
👎Deprecated since 0.6.0: Please use value.funcall("local_variable_get", (name,))
instead.
pub fn local_variable_get<N, T>(self, name: N) -> Result<T, Error>where
N: IntoSymbol,
T: TryConvert,
value.funcall("local_variable_get", (name,))
instead.Get the named local variable from the binding.
Returns Ok(T)
if the method returns without error and the return
value converts to a T
, or returns Err
if the local variable does
not exist or the conversion fails.
§Examples
use magnus::{eval, Binding, Value};
let binding = eval::<Binding>("binding").unwrap();
binding.local_variable_set("a", 1);
assert_eq!(binding.local_variable_get::<_, i64>("a").unwrap(), 1);
assert!(binding.local_variable_get::<_, Value>("b").is_err());
sourcepub fn local_variable_set<N, T>(self, name: N, val: T)where
N: IntoSymbol,
T: IntoValue,
👎Deprecated since 0.6.0: Please use value.funcall("local_variable_set", (name, val))
instead.
pub fn local_variable_set<N, T>(self, name: N, val: T)where
N: IntoSymbol,
T: IntoValue,
value.funcall("local_variable_set", (name, val))
instead.Set the named local variable in the binding.
§Examples
use magnus::{eval, Binding};
let binding = eval::<Binding>("binding").unwrap();
binding.local_variable_set("a", 1);
assert_eq!(binding.local_variable_get::<_, i64>("a").unwrap(), 1);
Trait Implementations§
source§impl Object for Binding
impl Object for Binding
source§fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a singleton method in
self
’s scope. Read moresource§impl ReprValue for Binding
impl ReprValue for Binding
source§fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#==
. Read moresource§fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#eql?
. Read moresource§fn hash(self) -> Result<Integer, Error>
fn hash(self) -> Result<Integer, Error>
Returns an integer non-uniquely identifying
self
. Read moresource§fn to_bool(self) -> bool
fn to_bool(self) -> bool
Convert
self
to a bool
, following Ruby’s rules of false
and nil
as boolean false
and everything else boolean true
. Read moresource§fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
source§fn block_call<M, A, R, T>(
self,
method: M,
args: A,
block: fn(_: &[Value], _: Option<Proc>) -> R
) -> Result<T, Error>
fn block_call<M, A, R, T>( self, method: M, args: A, block: fn(_: &[Value], _: Option<Proc>) -> R ) -> Result<T, Error>
source§fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
Check if
self
responds to the given Ruby method. Read moresource§fn is_kind_of<T>(self, class: T) -> bool
fn is_kind_of<T>(self, class: T) -> bool
source§fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
source§impl TryConvert for Binding
impl TryConvert for Binding
impl Copy for Binding
Auto Trait Implementations§
impl Freeze for Binding
impl RefUnwindSafe for Binding
impl Send for Binding
impl Sync for Binding
impl Unpin for Binding
impl UnwindSafe for Binding
Blanket Implementations§
source§impl<T> AsRawValue for Twhere
T: ReprValue,
impl<T> AsRawValue for Twhere
T: ReprValue,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more