mirror of https://github.com/tildeio/helix
Add slice -> Ruby array
This commit is contained in:
parent
f584a08f5b
commit
ff2a9d2a59
|
@ -6,6 +6,7 @@ mod float;
|
|||
mod string;
|
||||
mod option;
|
||||
mod result;
|
||||
mod slice;
|
||||
mod vec;
|
||||
|
||||
use sys::{VALUE};
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
use super::{ToRuby, ToRubyResult};
|
||||
use sys::{rb_ary_new_capa, rb_ary_push};
|
||||
|
||||
impl<'a, T> ToRuby for &'a [T] where &'a T: ToRuby {
|
||||
fn to_ruby(self) -> ToRubyResult {
|
||||
let ary = unsafe { rb_ary_new_capa(self.len() as isize) };
|
||||
for item in self {
|
||||
unsafe { rb_ary_push(ary, item.to_ruby()?); }
|
||||
}
|
||||
Ok(ary)
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
use sys;
|
||||
use sys::{VALUE};
|
||||
use sys::{self, VALUE};
|
||||
|
||||
use super::{CheckResult, FromRuby, ToRuby, ToRubyResult};
|
||||
use super::super::{inspect};
|
||||
|
|
Loading…
Reference in New Issue