-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Clarification: Use Slice instead of Array #14102
Conversation
There actually are arrays. They're fixed-size. Sometimes called fixed-sized vectors, sometimes called fixed-sized arrays, and sometimes just called arrays. I think standardizing on the final term is appropriate. This is a type of the form |
@@ -1678,7 +1678,7 @@ contained value are destroyed. | |||
~~~ | |||
use std::rc::Rc; | |||
|
|||
// A fixed-size array allocated in a reference-counted box | |||
// A slice allocated in a reference-counted box |
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.
Unfortunately this one and the Gc
one are actually legitimately fixed-size arrays (the internal bit has type [int, .. 10]
).
An array is a contiguous sequence of values with a statically-known length. A slice is An array will implicitly coerce into a slice as necessary (e.g. because you're passing it to a method that requires a slice). |
The preferred terms are the following:
|
Thank you so much for all your feedback 👍 |
Adjusted everything to your comments. Mind to check again? @kballard Ok, I think I'm not ready yet to commit code to Rust itself 😉 But I will look into |
@moonglum |
Thanks for explaining those three concepts. Puh! I have to let that sink in I guess 😉 |
@@ -2428,9 +2428,9 @@ fn draw_all<T: Drawable>(shapes: ~[T]) { | |||
# draw_all(~[c]); | |||
~~~~ | |||
|
|||
You can call that on an array of circles, or an array of rectangles | |||
You can call that on a slice of circles, or a slice of rectangles |
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.
Both "slice"s in this line should be "vector"s.
Especially in the tutorial beginners should not be confused with wrong terminology. It helps to know the right names for things when you want to find something in the documentation.
Ok, I adjusted the |
There's still code in the tutorial that uses My suggestion is to drop the |
Ok, removed that commit from this pull request. Will do a separate one and hunt for all the cases in the tutorial. |
Thanks for your patience with my tiny, tiny pull request 👍 |
…=kballard There are no arrays in Rust, they are slices. Especially in the tutorial beginners should not be confused with wrong terminology. It helps to know the right names for things when you want to find something in the documentation. @erickt explained that today to me and it helped me a lot when getting started 😉 Maybe we should also explain what a slice and what a vector is in the tutorial. If you like that, I will try to do that and attach that to the pull request 😉
👯 |
minor: Bump `rustc-ap-rustc_lexer` Closes rust-lang/rust-analyzer#9554
Labeled blocks cannot be used as-is in the "then" or "else" part of an `if` expression. They must be enclosed in an anonymous block. Fix rust-lang#14099 changelog: [`match_bool`]: fix suggestion when the rewritten block has a label
There are no arrays in Rust, they are slices. Especially in the tutorial beginners should not be confused with wrong terminology. It helps to know the right names for things when you want to find something in the documentation.
@erickt explained that today to me and it helped me a lot when getting started 😉 Maybe we should also explain what a slice and what a vector is in the tutorial. If you like that, I will try to do that and attach that to the pull request 😉