Skip to content
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

fix(primitive_types4): Fail on a slice covering the wrong area #209

Merged
merged 1 commit into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/primitive_types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ compiler. In this section, we'll go through the most important ones.
#### Book Sections

- [Data Types](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html)
- [The Slice Type](https://doc.rust-lang.org/stable/book/ch04-03-slices.html)
29 changes: 24 additions & 5 deletions exercises/primitive_types/primitive_types4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
// Get a slice out of Array a where the ??? is so that the `if` statement
// returns true. Scroll down for hints!!

#[test]
fn main() {
let a = [1, 2, 3, 4, 5];

let nice_slice = ???

if nice_slice == [2, 3, 4] {
println!("Nice slice!");
} else {
println!("Not quite what I was expecting... I see: {:?}", nice_slice);
}
assert_eq!([2, 3, 4], nice_slice)
}


Expand All @@ -33,6 +30,28 @@ fn main() {




























Expand Down
2 changes: 1 addition & 1 deletion info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mode = "compile"

[[exercises]]
path = "exercises/primitive_types/primitive_types4.rs"
mode = "compile"
mode = "test"

[[exercises]]
path = "exercises/primitive_types/primitive_types5.rs"
Expand Down