File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // Get a slice out of Array a where the ??? is so that the `if` statement
2+ // returns true. Scroll down for hints!!
3+
4+ fn main ( ) {
5+ let a = [ 1 , 2 , 3 , 4 , 5 ] ;
6+
7+ let nice_slice = ???
8+
9+ if nice_slice == [ 2 , 3 , 4 ] {
10+ println ! ( "Nice slice!" ) ;
11+ } else {
12+ println ! ( "Not quite what I was expecting... I see: {:?}" , nice_slice) ;
13+ }
14+ }
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+ // Take a look at the Primitive Types -> Slices section of the book:
41+ // http://doc.rust-lang.org/stable/book/primitive-types.html#slices
42+ // and use the starting and ending indices of the items in the Array
43+ // that you want to end up in the slice.
44+
45+ // If you're curious why the right hand of the `==` comparison does not
46+ // have an ampersand for a reference since the left hand side is a
47+ // reference, take a look at the Deref coercions chapter:
48+ // http://doc.rust-lang.org/stable/book/deref-coercions.html
You can’t perform that action at this time.
0 commit comments