Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the RString API using Rust's String/str instead of Vec<u8>/[u8]? #97

Open
CodesInChaos opened this issue May 20, 2018 · 1 comment

Comments

@CodesInChaos
Copy link

My understanding is that Ruby's strings are sequences of arbitrary bytes, even if the associated encoding is UTF-8. So the natural mapping to Rust would be as [u8] and Vec<u8> instead of str and String for most purposes. A couple of helpers using str should be fine (e.g. the from_utf8 function).

Functions which convert a ruby string to &str or String without verifying UTF-8 validity must be marked unsafe, otherwise they're unsound.

@danielpclark
Copy link
Contributor

danielpclark commented Jun 2, 2018

Thanks for opening this issue. I'm going to be investigating encoding support through ruru this month so this info may come in to play. I'll be sure to provide any useful information I find on this then here.

I've been waiting for @d-unseductable to reappear on the scene of his project here and hoping to get this project moving forward. I don't know how long I'm willing to wait but I'm pretty close to making an official fork of this project (although I would be much happier as a co-maintainer of this project after discussing with Dmitry what his vision for the future of ruru is) and re-implement a few key components to be safer such as you've suggested. One such change is that new class instantiation should return a Result<AnyObject, AnyException> rather than AnyObject as Ruby is fully capable of raising exceptions in class instantiation. I've opened an issue for discussion on that specific point here: #91

But my hope is really to see this project thrive and do well so I'm still holding out hoping Dmitry shows up to revive this project.

It looks like Helix just took this issue on for their project here: tildeio/helix@faaa6b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants