Skip to content

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

Merged
merged 1 commit into from
Apr 27, 2014

Conversation

jacob-hegna
Copy link
Contributor

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).

@@ -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)
Copy link
Member

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.

@jacob-hegna
Copy link
Contributor Author

@alexcrichton fixed

///
/// ```
/// std::int::to_str_bytes(123, 10, |v| {
/// assert!(v == unsafe{std::cast::transmute("123")});
Copy link
Member

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?

Copy link
Contributor Author

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

@jacob-hegna
Copy link
Contributor Author

@alexcrichton changed the documentation to reflect your comments and updated std::i64::parse_bytes in uint_macros.rs to std::uint::parse_bytes

@alexcrichton
Copy link
Member

Looks good to me, thanks! Could you squash these commits into just one as well?

@jacob-hegna
Copy link
Contributor Author

squashed

@alexcrichton
Copy link
Member

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?

@jacob-hegna
Copy link
Contributor Author

haha sorry about that

bors added a commit that referenced this pull request Apr 27, 2014
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).
@bors bors closed this Apr 27, 2014
@bors bors merged commit b8f5090 into rust-lang:master Apr 27, 2014
arcnmx pushed a commit to arcnmx/rust that referenced this pull request Dec 17, 2022
Add a command to clear flycheck diagnostics

And document the flycheck notifications
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.

3 participants