1. 15
    Rustlings primitive_types2: String and Character literals using different quote styles
    47s

Rustlings primitive_types2: String and Character literals using different quote styles

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

README for this exercise.

Chris Biscardi: [0:00] In primitive_types 2, we have a main() function with a body that sets my_first_initial the character 'C.' We know this is a character because we use single quotes here. Double quotes indicates a string. We have a number of functions that are called on a character that don't exist on strings.

[0:15] On line 19, we have to finish the line. Note that the error message doesn't do us much good here because we need to finish the let line which is missing code. In this case, we'll take your_character which is the variable that we need and try to set it to a string.

[0:31] You'll know that because we use double quotes. There's no method named is_alphabetic bound for reference and string in the current scope. If we change this to use single quotes and remember to add our semicolon, then our tests pass is_alphabetic and is_numeric are functions on characters, not strings.