Skip to content

Commit e16fc30

Browse files
authored
Merge pull request #4118 from rust-lang/push-tskzrxpsrmox
Fix confusion between variable `hello` and string `"hello"`
2 parents ef5b909 + daf8d82 commit e16fc30

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ch08-02-strings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ seem that `answer` should in fact be `208`, but `208` is not a valid character
278278
on its own. Returning `208` is likely not what a user would want if they asked
279279
for the first letter of this string; however, that’s the only data that Rust
280280
has at byte index 0. Users generally don’t want the byte value returned, even
281-
if the string contains only Latin letters: if `&"hello"[0]` were valid code
282-
that returned the byte value, it would return `104`, not `h`.
281+
if the string contains only Latin letters: if `&"hi"[0]` were valid code that
282+
returned the byte value, it would return `104`, not `h`.
283283

284284
The answer, then, is that to avoid returning an unexpected value and causing
285285
bugs that might not be discovered immediately, Rust doesn’t compile this code

0 commit comments

Comments
 (0)