CleanCut/ultimate_rust2

Challenge clarification for "errors" exercise

Closed this issue · 1 comments

ultimate_rust2/exercise/errors

Based on the description:

        // Challenge: Change main() so that it returns a Result, and instead of handling the error   
        // that play_time returns, use the try operator to only handle the success condition. How   
        // does the output of the program change?   

the following change is made:

fn main() -> Result<()> {   
    ...   
    for dolphin in &dolphins {   
        let responses = play_time(dolphin)?;   
        println!("{} did a FABULOUS PERFORMANCE!", dolphin.name);   
        for response in responses {   
            println!("  {}", response);   
        }   
    }   
    Ok(())   
}   

It changes the output of the program to:
Error: The dolphin's name is too long and annoying to say

Did I understand the challenge correctly and was it the correct solution?
Or anything should be done to explicitly ignore the error Result returned by play_time() and yet to consume the Ok Result?
Please advise.

Yes, that's exactly the right output after making the change. You are not the first person to ask this question, so I will go and update the text to make it clear that this is the expected solution!