1
Fork 0

auto merge of #14102 : moonglum/rust/slice-clarification-in-readme, r=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 😉
This commit is contained in:
bors 2014-05-11 14:51:46 -07:00
commit f483aa3a91

View file

@ -2385,7 +2385,7 @@ fn print_all<T: Printable>(printable_things: ~[T]) {
Declaring `T` as conforming to the `Printable` trait (as we earlier Declaring `T` as conforming to the `Printable` trait (as we earlier
did with `Clone`) makes it possible to call methods from that trait did with `Clone`) makes it possible to call methods from that trait
on values of type `T` inside the function. It will also cause a on values of type `T` inside the function. It will also cause a
compile-time error when anyone tries to call `print_all` on an array compile-time error when anyone tries to call `print_all` on a vector
whose element type does not have a `Printable` implementation. whose element type does not have a `Printable` implementation.
Type parameters can have multiple bounds by separating them with `+`, Type parameters can have multiple bounds by separating them with `+`,
@ -2428,9 +2428,9 @@ fn draw_all<T: Drawable>(shapes: ~[T]) {
# draw_all(~[c]); # draw_all(~[c]);
~~~~ ~~~~
You can call that on an array of circles, or an array of rectangles You can call that on a vector of circles, or a vector of rectangles
(assuming those have suitable `Drawable` traits defined), but not on (assuming those have suitable `Drawable` traits defined), but not on
an array containing both circles and rectangles. When such behavior is a vector containing both circles and rectangles. When such behavior is
needed, a trait name can alternately be used as a type, called needed, a trait name can alternately be used as a type, called
an _object_. an _object_.