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(ruby: &magnus::Ruby) -> Result<(), magnus::Error> {
ruby.define_class("RbPoint", ruby.class_object())?;
Ok(())
}
Attribute Macros§
- init
- Mark a function as the ‘init’ function to be run for a library when it is
require
d by Ruby code. - wrap
- Allows a Rust type to be passed to Ruby, where it is automatically wrapped as a Ruby object.
Derive Macros§
- Data
Type Functions - Derives
DataTypeFunctions
with default implementations, for simple uses ofTypedData
. - Typed
Data - Derives
TypedData
, allowing a Rust type to be passed to Ruby and automatically wrapped as a Ruby object.