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

Using AsRef<[u8]> in Arguments #6

Open
gsquire opened this issue Nov 13, 2018 · 8 comments
Open

Using AsRef<[u8]> in Arguments #6

gsquire opened this issue Nov 13, 2018 · 8 comments

Comments

@gsquire
Copy link

gsquire commented Nov 13, 2018

This may have been a conscious choice to avoid but I wanted to see if it makes sense to use some type that implements AsRef<[u8]> in place of &[u8]? This would make it easy for users to supply &str or String in addition to &[u8] when calling functions. I thought this would be in line with the idea that mundane is intended to be easy to use.

@jswrenn
Copy link

jswrenn commented Nov 13, 2018

I think you mean AsRef<[u8]>. This is a good idea. It would also make passing in [u8] just a tiny bit more ergonomic.

@gsquire
Copy link
Author

gsquire commented Nov 13, 2018

@jswrenn You're right. I forgot the slice notation in my comment :)

Updated.

@pop
Copy link

pop commented Jan 18, 2019

Has anybody started working on this? I'm interested in contributing to this project and the experience-easy got my attention. Any guidance or pointers on how/where to get started would be awesome.

@gsquire
Copy link
Author

gsquire commented Jan 18, 2019

Hey @pop, I started on it here but if you are looking to contribute, feel free to take it over. I am by no means an expert (or the maintainer) but I would be happy to give some guidance if you'd like. Hope you find it to be fun!

@joshlf
Copy link
Member

joshlf commented Jan 18, 2019

Hey folks! Sorry I've been silent on this issue; I've been swamped with other stuff.

@gsquire I did see your submission. I'll be honest, I'm kinda on the fence about this in general. I agree that, in general, taking AsRef<[u8]> is more ergonomic for callers. However, in the case of cryptography in particular, there's a benefit to forcing the caller to be more explicit in what they're doing since it can often have security implications. In other words, if calling as_ref can have side effects, it's probably not good for Mundane to be calling it implicitly. It's not that much of a burden for a caller to do foo(arg.as_ref()) instead of foo(arg), and the former makes it much clearer to others reading the code that as_ref is being called.

I'm happy to hear alternative perspectives on this, though!

@gsquire
Copy link
Author

gsquire commented Jan 18, 2019

All good! I made this issue as more of a question than anything. Thanks for sharing your input though. I can close my patch and this issue unless anyone has a more salient point than I do.

@joshlf
Copy link
Member

joshlf commented Jan 18, 2019

Please don't think of this as me shutting this down - it's just my opinion.

And in any case, even if we end up deciding to close this, we'd love to have your contributions on other issues! There's much work to be done :)

@pop
Copy link

pop commented Jan 21, 2019

Hey @pop, I started on it here but if you are looking to contribute, feel free to take it over. I am by no means an expert (or the maintainer) but I would be happy to give some guidance if you'd like. Hope you find it to be fun!

No worries, it's all yours @gsquire.

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

No branches or pull requests

4 participants