Skip to content

Commit 76a36dd

Browse files
committed
chore: update errors1 comments and hint
1 parent c39eb3f commit 76a36dd

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

exercises/error_handling/errors1.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// errors1.rs
22
// This function refuses to generate text to be printed on a nametag if
33
// you pass it an empty string. It'd be nicer if it explained what the problem
4-
// was, instead of just sometimes returning `None`. The 2nd test currently
5-
// does not compile or pass, but it illustrates the behavior we would like
6-
// this function to have.
4+
// was, instead of just sometimes returning `None`. Thankfully, Rust has a similar
5+
// construct to `Option` that can be used to express error conditions. Let's use it!
76
// Execute `rustlings hint errors1` for hints!
87

98
// I AM NOT DONE
@@ -21,9 +20,6 @@ pub fn generate_nametag_text(name: String) -> Option<String> {
2120
mod tests {
2221
use super::*;
2322

24-
// This test passes initially if you comment out the 2nd test.
25-
// You'll need to update what this test expects when you change
26-
// the function under test!
2723
#[test]
2824
fn generates_nametag_text_for_a_nonempty_name() {
2925
assert_eq!(

info.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ name = "errors1"
490490
path = "exercises/error_handling/errors1.rs"
491491
mode = "test"
492492
hint = """
493-
`Err` is one of the variants of `Result`, so what the 2nd test is saying
493+
`Ok` and `Err` are one of the variants of `Result`, so what the tests are saying
494494
is that `generate_nametag_text` should return a `Result` instead of an
495495
`Option`.
496496
@@ -500,9 +500,7 @@ To make this change, you'll need to:
500500
- change the body of the function to return `Ok(stuff)` where it currently
501501
returns `Some(stuff)`
502502
- change the body of the function to return `Err(error message)` where it
503-
currently returns `None`
504-
- change the first test to expect `Ok(stuff)` where it currently expects
505-
`Some(stuff)`."""
503+
currently returns `None`"""
506504

507505
[[exercises]]
508506
name = "errors2"

0 commit comments

Comments
 (0)