1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::convert::FromMrb;
use crate::sys;
use crate::value::types::{Ruby, Rust};
use crate::value::Value;
use crate::Mrb;
mod array;
mod boolean;
mod bytes;
mod fixnum;
mod float;
mod string;
pub use self::array::*;
pub use self::boolean::*;
pub use self::bytes::*;
pub use self::fixnum::*;
pub use self::float::*;
pub use self::string::*;
impl FromMrb<Option<Value>> for Value {
type From = Rust;
type To = Ruby;
fn from_mrb(interp: &Mrb, value: Option<Self>) -> Self {
match value {
Some(value) => value,
None => Self::new(interp, unsafe { sys::mrb_sys_nil_value() }),
}
}
}
impl FromMrb<Value> for Option<Value> {
type From = Ruby;
type To = Rust;
fn from_mrb(_interp: &Mrb, value: Value) -> Self {
match value.ruby_type() {
Ruby::Nil => None,
_ => Some(value),
}
}
}