-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Document init of HashSet/HashMap from vector #36740
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
/// [ ("Norway", 100), | ||
/// ("Denmark", 50), | ||
/// ("Iceland", 10) ] | ||
/// .iter().map(|&x| x).collect(); |
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.
.cloned()
can be used instead of .map(|&x| x)
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.
comment merged in
@@ -335,6 +335,20 @@ fn test_resize_policy() { | |||
/// println!("{:?} has {} hp", viking, health); | |||
/// } | |||
/// ``` | |||
/// A HashMap with fixed list of elements can be initialized from vector: |
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.
"from an array"
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.
comments have been merged in
@@ -100,6 +100,18 @@ const INITIAL_CAPACITY: usize = 32; | |||
/// println!("{:?}", x); | |||
/// } | |||
/// ``` | |||
/// HashSet with fixed list of elements can be initialized from vector: |
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.
"from an array"
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.
Some small nits!
/// | ||
/// fn main() { | ||
/// let timber_resources: HashMap<&str, i32> = | ||
/// [ ("Norway", 100), |
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.
the space between [(
should go away
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.
done
/// let timber_resources: HashMap<&str, i32> = | ||
/// [ ("Norway", 100), | ||
/// ("Denmark", 50), | ||
/// ("Iceland", 10) ] |
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.
same here
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.
done
/// [ ("Norway", 100), | ||
/// ("Denmark", 50), | ||
/// ("Iceland", 10) ] | ||
/// .iter().cloned().collect(); |
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.
does into_iter work here, rather than iter.cloned()?
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.
no, I tried
@@ -100,6 +100,18 @@ const INITIAL_CAPACITY: usize = 32; | |||
/// println!("{:?}", x); | |||
/// } | |||
/// ``` | |||
/// HashSet with fixed list of elements can be initialized from an array: |
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.
can you put a newline above and below this line, please?
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.
done
@@ -335,6 +335,20 @@ fn test_resize_policy() { | |||
/// println!("{:?} has {} hp", viking, health); | |||
/// } | |||
/// ``` | |||
/// A HashMap with fixed list of elements can be initialized from an array: |
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.
can you put a newline before and after this line please?
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.
done
all comments merged in |
@bors: r+ rollup thank you! |
📌 Commit f953d25 has been approved by |
Sadly I don't have permissions to merge :( Will anybody merge this in now? |
@frehberg @bors will do it automatically, you just have to wait. :) once we say |
Document init of HashSet/HashMap from vector
No description provided.