Upgrading from 0.7 to 0.8
-
Change
use ruru::traits::Object
touse ruru::Object
. -
Some general methods were moved to
Object
trait, so importruru::Object
when using:
AnyObject::to()
AnyObject::ty()
Class::define()
Class::define_method()
Class::define_singleton_method()
-
Object::to()
(AnyObject::to()
in 0.7.x) was marked as unsafe.
object.to::<Array>();
becomes
unsafe { object.to::<Array>() };
-
methods!
macro:
-
If you are sure that arguments that are received from Ruby always have correct types, change
methods!
macro tounsafe_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 typearray: Result<Array, Error>
See documentation for
methods!
for more examples.
-
Class::new()
receives optional superclass, so addNone
as second argument for compatibilityClass::new("SomeClass", None);
-
Hash::each
was changed to yield keys and values only asAnyObject
s.You should remove types from closure arguments and use safe/unsafe conversions to convert
AnyObject
s to the type which is needed.