-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add some examples to std::string #30770
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
I think in order to actually fix #30345 there should be a mention of the word "concatenation", perhaps in the description and examples for |
//! | ||
//! let bytes = sparkle_heart.into_bytes(); | ||
//! | ||
//! assert_eq([240, 159, 146, 150, 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.
Should probably be:
assert_eq!(bytes, [240, 159, 146, 150]);
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.
For what reason?
Good call on putting the word 'concatenation' |
//! | ||
//! let bytes = sparkle_heart.into_bytes(); | ||
//! | ||
//! assert_eq([240, 159, 146, 150], 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.
!
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.
and the arguments still need to be swapped because PartialEq<Vec<u8>>
is not implemented for [u8; 4]
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.
ugh, how did this pass for me locally, then?
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.
What's your test setup / make command?
On Jan 8, 2016 11:02, "Steve Klabnik" notifications@github.com wrote:
In src/libcollections/string.rs
#30770 (comment):+//!
+//! +//! If you have a vector of valid UTF-8 bytes, you can make a
Stringout of +//! it. You can do the reverse too. +//! +//!
rust
+//! let sparkle_heart = vec![240, 159, 146, 150];
+//!
+//! // We know these bytes are valid, so we'll useunwrap()
.
+//! let sparkle_heart = String::from_utf8(sparkle_heart).unwrap();
+//!
+//! assert_eq!("💖", sparkle_heart);
+//!
+//! let bytes = sparkle_heart.into_bytes();
+//!
+//! assert_eq([240, 159, 146, 150], bytes);ugh, how did this pass for me locally, then?
—
Reply to this email directly or view it on GitHub
https://github.com/rust-lang/rust/pull/30770/files#r49203568.
@bors r+ |
📌 Commit 51b11ca has been approved by |
⌛ Testing commit 51b11ca with merge 18f97a7... |
💔 Test failed - auto-mac-64-nopt-t |
@bors: r=brson rollup :( |
📌 Commit b6cc099 has been approved by |
Fixes rust-lang#30345 I'm not sure if there's anything else that belongs here. Thoughts?
Fixes #30345
I'm not sure if there's anything else that belongs here. Thoughts?