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

core: impl LowerHex and UpperHex for [u8] #26331

Closed
wants to merge 2 commits into from

Conversation

richo
Copy link
Contributor

@richo richo commented Jun 16, 2015

This is a fairly speculative PR, since I have a bunch of open questions:

  • Is it actually as much work as it looks to implement this without the Debug bound? (Is that desirable? Happy to do it if it would get merged)
  • Is marking this stable OK? It seems pretty minor
  • More subjectively, this seemed to be right on the cusp of worth macro-ifying. I suspect that it's actually worth doing this for all of [u8], [u16] and friends, so I presume that I should actually macro it?

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@richo
Copy link
Contributor Author

richo commented Jun 16, 2015

@aturon: Feel free to ignore the details of the implementation, I ran the tests overnight and it's broken, but I'd love feedback on the concept/the questions in the PR.

@alexcrichton
Copy link
Member

This was originally proposed in #19670 (in a more general form) which was PR'd in #25319, but was closed due to concerns about the usefulness.

I feel like if we take this route we'd want to take the more general approach, but I think I still feel that this may not want to be in the standard library just yet.

@richo
Copy link
Contributor Author

richo commented Jun 16, 2015

Interesting, thanks for the background. Based on your comment on #25319, would I be better off championing this in an RFC or an internals thread? I totally understand the conservative approach, but I'm pretty convinced that this, or something that looks a lot like this, is going to be something that crops up again and again.

As an example, I work with binary data a lot, and having no easy way to spit out internal representation in a way that can be easily compared to xxd introduces a lot of copying and pasting into a python repl into my workflow that I'd really rather avoid.

@richo richo closed this Jun 16, 2015
@alexcrichton
Copy link
Member

would I be better off championing this in an RFC or an internals thread?

Yeah I think that'd be a good place to start a conversation for this, thanks!

@vi
Copy link
Contributor

vi commented Nov 10, 2017

Are there any updates for the feature?

It's not convenient to copy and paste things from [191, 0, 24, 33, into calculator (or to complexify temporary println! with a loop, or wait for crates.io index update because of silly mini-dependency like hex_slice) just to see if some bit is set in n'th byte.

@stevenroose
Copy link

I always thought this was impossible because it would conflict with impl<T: LowerHex> LowerHex for [T], but that implementation doesn't exist. Why on earth can't we have LowerHex for [u8] and Vec<u8> then? Basically AsRef<[u8]>??

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

Successfully merging this pull request may close these issues.

6 participants