Skip to content

bytes!() could be more versatil #6556

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

Closed
Kimundi opened this issue May 17, 2013 · 2 comments
Closed

bytes!() could be more versatil #6556

Kimundi opened this issue May 17, 2013 · 2 comments

Comments

@Kimundi
Copy link
Member

Kimundi commented May 17, 2013

At the moment, bytes!() just converts a string literal into a &[u8].

However, to be even more useful for low level stuff it could accept a list of anything reasonably convertible to a list of u8s, like strings, chars in ascii range, explicit u8s etc.

Then you could do for example:

  • bytes!("foo", 0) - vector of the bytes in "foo" and a null terminator.
  • bytes!('a', 42, 'b', 98, 'c', 255) - some kind of binary data format.
  • bytes!(" ", ' ', 32) - a vector of three 32u8.
@Kimundi
Copy link
Member Author

Kimundi commented May 18, 2013

I implemented the neccessary changes for this, this can now be closed.

@jdm
Copy link
Contributor

jdm commented May 18, 2013

7a2afb7

@jdm jdm closed this as completed May 18, 2013
Jarcho pushed a commit to Jarcho/rust that referenced this issue Feb 26, 2023
Change unusual_byte_groupings to require byte groupings of equal size

Fixes issue rust-lang#6556

This lint required byte groupings of size 2 or 4 for `Radix::Binary` and `Radix::Hexadecimal`. Since there are good reasons for allowing groups of other sizes, this PR relaxes the restriction. This lint now requires that

- group sizes after the first group be of the same size and
- greater or equal in size to the first group.

---

changelog: [`unusual_byte_groupings`]: reduce false positives by relaxing restriction requiring groups of specific sizes.
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