src/helpers.rs in faster_path-0.2.2 vs src/helpers.rs in faster_path-0.2.3

- old
+ new

@@ -1,20 +1,8 @@ -extern crate ruby_sys; -use self::ruby_sys::string; +use ruru::{AnyObject, Class, Object, RString}; -use ruru::{AnyObject, Class}; -use ruru::types::{c_char, c_long, Value}; - -#[inline] -pub fn str_to_value(string: &str) -> Value { - let str_ptr = string.as_ptr() as *const c_char; - let len = string.len() as c_long; - - unsafe { string::rb_str_new(str_ptr, len) } -} - pub fn str_to_any_obj(str_var: &str) -> AnyObject { - AnyObject::from(str_to_value(str_var)) + RString::new(str_var).to_any_object() } pub fn class_new(klass: &str, params: Vec<AnyObject>) -> AnyObject { Class::from_existing(klass).new_instance(params) }