Crate magnus_macros
source ·Expand description
Derive and proc macros for magnus.
#[magnus::wrap(class = "RbPoint", free_immediately, size)]
struct Point {
x: isize,
y: isize,
}
#[magnus::init]
fn init() -> Result<(), magnus::Error> {
magnus::define_class("RbPoint", Default::default())?;
Ok(())
}
Attribute Macros
Mark a function as the ‘init’ function to be run for a library when it is
require
d by Ruby code.Allow a Rust type to be passed to Ruby, automatically wrapped as a Ruby
object.
Derive Macros
Derives
DataTypeFunctions
with default implementations, for simple uses
of TypedData
.Derives
TypedData
, allowing the type to be passed to Ruby automatically
wrapped as a Ruby object.