- 授权协议: MIT
- 开发语言: Rust
- 操作系统: 跨平台
- 软件首页: https://github.com/anima-engine/mrusty
- 软件文档: https://github.com/anima-engine/mrusty
软件介绍
mrusty 可以让你在 mruby 中使用 Rust 的结构和枚举并运行它们。
示例代码:
// mrfn!
#[macro_use]
extern crate mrusty;
// Needs some undocumented, hidden calls.
use mrusty::*;
let mruby = MRuby::new();
struct Cont {
value: i32
}
// Cont should not flood the current namespace. We will add it with require.
impl MRubyFile for Cont {
fn require(mruby: MRubyType) {
mruby.def_class::<Cont>("Container");
// Converts mruby types automatically & safely.
// slf is always Value in initialize().
mruby.def_method::<Cont, _>("initialize", mrfn!(|_mruby, slf: Value, v: i32| {
let cont = Cont { value: v };
slf.init(cont)
}));
mruby.def_method::<Cont, _>("value", mrfn!(|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".
程序员成长的烦恼
吴亮、周金桥、李春雷、周礼 / 华中科技大学出版社 / 2011-4 / 28.00元
还在犹豫该不该转行学编程?还在编程的道路上摸爬滚打?在追寻梦想的道路上你并不孤单,《程序员成长的烦恼》中的四位“草根”程序员也曾有过类似的困惑。看看油田焊接技术员出身的周金桥是如何成功转行当上程序员的,做过钳工、当过外贸跟单员的李春雷是如何自学编程的,打小在486计算机上学习编程的吴亮是如何一路坚持下来的,工作中屡屡受挫、频繁跳槽的周礼是如何找到出路的。 《程序员成长的烦恼》记录了他们一步一......一起来看看 《程序员成长的烦恼》 这本书的介绍吧!
