-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Documentation for parse_bytes and to_str_bytes in {int, uint}_macros.rs #13792
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
Conversation
@@ -234,16 +234,17 @@ impl Primitive for $T {} | |||
|
|||
// String conversion functions and impl str -> num | |||
|
|||
/// Parse a byte slice as a number in the given base. | |||
/// Parse a byte slice as a number in the given base (big endian) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this mention of endianness is quite right. Endianness usually deals with the binary representation of the integer in memory, but here we're just parsing a sequence of bytes, interpreted as characters, into an integer. There is no inherent endianness going on here.
@alexcrichton fixed |
/// | ||
/// ``` | ||
/// std::int::to_str_bytes(123, 10, |v| { | ||
/// assert!(v == unsafe{std::cast::transmute("123")}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't catch this earlier, but I don't think examples should be using unsafe code. Why is this using transmute rather than as_bytes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that function escaped me when writing the example, my bad
@alexcrichton changed the documentation to reflect your comments and updated std::i64::parse_bytes in uint_macros.rs to std::uint::parse_bytes |
Looks good to me, thanks! Could you squash these commits into just one as well? |
squashed |
It's ok if you don't preserve the exact history of the squashed commits, could you update the commit message to reflect what ended up getting changed? |
haha sorry about that |
Just modified the documentation for parse_bytes to make it more clear how the bytes were parsed (big endian) and to show an example of what it returned. I also added documentation for the to_str_bytes which previously had no documentation (besides one stackoverflow post).
Add a command to clear flycheck diagnostics And document the flycheck notifications
Just modified the documentation for parse_bytes to make it more clear how the bytes were parsed (big endian) and to show an example of what it returned. I also added documentation for the to_str_bytes which previously had no documentation (besides one stackoverflow post).