0.0
No commit activity in last 3 years
No release in over 3 years
A ruby gem that generates bindings to rust files automatically.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.4
~> 2.99

Runtime

~> 1.9
 Project Readme

rust_require

Gem Version

Overview

This gem imports a rust file similar to how require imports a ruby file. It creates wrappers for all rust functions marked pub, including type conversions for more complex things like strings.

rust_require makes ruby to rust interop completely automatic and convenient (also fast and memory safe).

Internally it makes heavy use of the awesome ffi gem and should as a result work with all three major ruby implementations.

Install

gem install rust_require

Usage

script.rb

require 'rust_require'

class Calculator
  rust_require 'calc.rs'
end

c = Calculator.new
c.add(2,3) # => "2 + 3 = 5"
c.mul(4,7) # => "4 * 7 = 28"

calc.rs

pub fn add(x:i64, y:i64) -> String { format!("{} + {} = {}", x, y, x+y) }
pub fn mul(x:i64, y:i64) -> String { format!("{} * {} = {}", x, y, x+y) }

Features

  • Supports rust macros
  • Supports free functions
  • Supports struct import
  • Imports the whole rust module tree

Supported types:

  • All primitive Integers
  • Currently no structs as types, but support is on the way