Why the complier fail to test


Anyone can tell me why there is a mismatched types error

Please don't share your code and error message as screenshots. Copy and paste them here and format them correctly. This allows us to copy and paste the code ourselves and also makes it accessible to people that rely on screen readers.

I think you can fix your code like this:

fn just_false() {
    let input = String::from("false");
+   let expected = vec![Token::False];
-   let expected = [Token::False];

    let actual = tokenize(input).unwrap();

    assert_eq!(actual, expected);
}

Arrays are a different and distinct type from Vec.

3 Likes

You are looking at the wrong piece of code. You have highlighted line 122, but the error is on line 94.

Thanks,my mistake

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.