Closed NullVoxPopuli closed 8 years ago
Hey @NullVoxPopuli!
I'll get to this in a couple of hours and explain how to do implement it the rust-way :)
Thanks for that! (You're pretty much my hero right now) :-)
Here is the ruby version in case intentions are unclear: https://github.com/NullVoxPopuli/case_transform/blob/77b154c62020d61d55a3186b73662bf105e84aac/lib/case_transform.rb
methods!
macro should be used to define only those methods which are exposed to Ruby (those ones which are used in def_self
in your example). You should move everything else out of the macro.
Long story short, Ruby methods and Rust functions are different and those functions which are declared inside methods!
macro are transformed during compile-time to be compatible with MRI.
So answering the title of the issue - no. Once you unwrap an object in a ruby method and pass it to Rust function, you won't need to unwrap it again.
As I see, you've tried to rewrite the Rust implementation the same way as the one in Ruby.
The code can be much simplier. Rust has a powerful type system and in ruru I try to reuse it for Ruby objects.
I will submit a PR to case_transform, because the code can tell much more than me :)
I guess I'm adding you to the authors list in my gemspec :-)
thanks a ton!
Rust looks really cool so far. Just different. haha
I'll close this issue. If you have more questions, please ask them in the PR comments.
cool beans
I feel like I'm needing to unwrap() everything to pass to other functions.
Here is what I have so far
I may also be struggling with Rust as I'm still fairly new to it -- and I may be trying too hard to adapt the ruby implementation I had of this to Rust (hence all the AnyObject / to_any_object everywhere). :-\
Here is the full repo, if you're interested: https://github.com/NullVoxPopuli/case_transform/blob/8f017c642a254388d6ca6b4c2aaee8f10fea0d17/ext/case_transform/src/lib.rs