Struct magnus::exception::ExceptionClass
source · pub struct ExceptionClass(/* private fields */);
Expand description
Implementations§
source§impl ExceptionClass
impl ExceptionClass
sourcepub fn from_value(val: Value) -> Option<Self>
pub fn from_value(val: Value) -> Option<Self>
Return Some(ExceptionClass)
if val
is an ExceptionClass
, None
otherwise.
§Examples
use magnus::{eval, ExceptionClass};
assert!(ExceptionClass::from_value(eval("StandardError").unwrap()).is_some());
assert!(ExceptionClass::from_value(eval(r#"StandardError.new("example")"#).unwrap()).is_none());
assert!(ExceptionClass::from_value(eval("Object").unwrap()).is_none());
Trait Implementations§
source§impl Class for ExceptionClass
impl Class for ExceptionClass
source§fn as_r_class(self) -> RClass
fn as_r_class(self) -> RClass
Return
self
as an RClass
.source§fn define_alloc_func<T>(self)
fn define_alloc_func<T>(self)
source§fn undef_default_alloc_func(self)
fn undef_default_alloc_func(self)
Remove the allocator function of a class if it is Ruby’s default
allocator function. Read more
source§impl Clone for ExceptionClass
impl Clone for ExceptionClass
source§fn clone(&self) -> ExceptionClass
fn clone(&self) -> ExceptionClass
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ExceptionClass
impl Debug for ExceptionClass
source§impl Display for ExceptionClass
impl Display for ExceptionClass
source§impl IntoValue for ExceptionClass
impl IntoValue for ExceptionClass
source§impl Module for ExceptionClass
impl Module for ExceptionClass
source§fn define_class<T>(self, name: T, superclass: RClass) -> Result<RClass, Error>where
T: IntoId,
fn define_class<T>(self, name: T, superclass: RClass) -> Result<RClass, Error>where
T: IntoId,
Define a class in
self
’s scope. Read moresource§fn define_module<T>(self, name: T) -> Result<RModule, Error>where
T: IntoId,
fn define_module<T>(self, name: T) -> Result<RModule, Error>where
T: IntoId,
Define a module in
self
’s scope. Read moresource§fn define_error<T>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>where
T: IntoId,
fn define_error<T>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>where
T: IntoId,
Define an exception class in
self
’s scope. Read moresource§fn is_inherited<T>(self, other: T) -> bool
fn is_inherited<T>(self, other: T) -> bool
source§fn ancestors(self) -> RArray
fn ancestors(self) -> RArray
Return the classes and modules
self
inherits, includes, or prepends. Read moresource§fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>
fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>
Define a method in
self
’s scope. Read moresource§fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a private method in
self
’s scope. Read moresource§fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a protected method in
self
’s scope. Read moresource§impl Object for ExceptionClass
impl Object for ExceptionClass
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 ExceptionClass
impl ReprValue for ExceptionClass
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 ExceptionClass
impl TryConvert for ExceptionClass
impl Copy for ExceptionClass
Auto Trait Implementations§
impl Freeze for ExceptionClass
impl RefUnwindSafe for ExceptionClass
impl Send for ExceptionClass
impl Sync for ExceptionClass
impl Unpin for ExceptionClass
impl UnwindSafe for ExceptionClass
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