Crate magnus_macros

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(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 required by Ruby code.
wrap
Allows a Rust type to be passed to Ruby, where it is automatically wrapped as a Ruby object.

Derive Macros§

DataTypeFunctions
Derives DataTypeFunctions with default implementations, for simple uses of TypedData.
TypedData
Derives TypedData, allowing a Rust type to be passed to Ruby and automatically wrapped as a Ruby object.