Skip to content

Upgrading from 0.7 to 0.8

Dmitry Gritsay edited this page Sep 21, 2016 · 2 revisions
  1. Change use ruru::traits::Object to use ruru::Object.

  2. Some general methods were moved to Object trait, so import ruru::Object when using:

  • AnyObject::to()
  • AnyObject::ty()
  • Class::define()
  • Class::define_method()
  • Class::define_singleton_method()
  1. Object::to() (AnyObject::to() in 0.7.x) was marked as unsafe.
object.to::<Array>();

becomes

unsafe { object.to::<Array>() };
  1. methods! macro:
  • If you are sure that arguments that are received from Ruby always have correct types, change methods! macro to unsafe_methods!. No more changes required.

  • Otherwise to safely convert objects, method arguments will have Result<T: Object, Error> type.

    For example if your method signature looks like

    fn some_method(array: Array) -> NilClass {}

    array variable will have type array: Result<Array, Error>

    See documentation for methods! for more examples.

  1. Class::new() receives optional superclass, so add None as second argument for compatibility

    Class::new("SomeClass", None);
  2. Hash::each was changed to yield keys and values only as AnyObjects.

    You should remove types from closure arguments and use safe/unsafe conversions to convert AnyObjects to the type which is needed.

Clone this wiki locally