프로젝트
GitHub에서 보기
anima-engine/mrusty
소개
mruby safe bindings for Rust
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalmrusty. mruby safe bindings for Rust
mrusty lets you:
- run Ruby 1.9 files with a very restricted API (without having to install Ruby)
- reflect Rust
structs andenums in mruby and run them
It does all this in a safely neat way, while also bringing spec testing and a REPL to the table.
Documentation
Example
A very simple example of a Container struct which will be passed to mruby and
which is perfectly callable.
// mrusty_class!
#[macro_use]
extern crate mrusty;
use mrusty::{Mruby, MrubyImpl};
let mruby = Mruby::new();
struct Cont {
value: i32
}
// Cont should not flood the current namespace. We will add it with require.
mrusty_class!(Cont, "Container", {
// Converts mruby types automatically & safely.
def!("initialize", |v: i32| {
Cont { value: v }
});
// Converts slf to Cont.
def!("value", |mruby, slf: (&Cont)| {
mruby.fixnum(slf.value)
});
});
// Add file to the context, making it requirable.
mruby.def_file::<Cont>("cont");
// Add spec testing.
describe!(Cont, "
context 'when containing 1' do
it 'returns 1 when calling #value' do
expect(Container.new(1).value).to eql 1
end
end
");
let result = mruby.run("
require 'cont'
Container.new(3).value
").unwrap(); // Returns Value.
println!("{}", result.to_i32().unwrap()); // Prints "3".
관련 프로젝트 살펴보기
불러오는 중…