Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 2 should explain that read_line appends to String. #2574

Closed
nothingnesses opened this issue Jan 20, 2021 · 1 comment · Fixed by #2575
Closed

Chapter 2 should explain that read_line appends to String. #2574

nothingnesses opened this issue Jan 20, 2021 · 1 comment · Fixed by #2575

Comments

@nothingnesses
Copy link
Contributor

nothingnesses commented Jan 20, 2021

I recently ran into an issue because I wrongly assumed that read_line overwrites the contents of a String instead of appending to it. I think a factor in this was that the explanation for the behaviour of read_line in Chapter 2 was a bit ambiguous. It turns out, I wasn't alone either, as someone else did something similar.

To prevent confusion in the future, I think it would be better if this sentence is changed to something like:

The job of `read_line` is to take whatever the user types into standard input
and append that into a string, so it takes that string as an argument.

Or even:

The job of `read_line` is to take whatever the user types into standard input
and append that into a string (without overwriting its contents), so it takes
that string as an argument.
carols10cents added a commit that referenced this issue Feb 12, 2021
Fix issue #2574 - Improve the explanation about the behaviour of `read_line`.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 17, 2021
Update books

## nomicon

1 commits in bbf06ad39d1f45654047e9596b750cc6e6d1b693..adca786547d08fe676b2fc7a6f08c2ed5280ca38
2021-01-22 07:07:31 -0800 to 2021-02-16 16:34:20 +0900
- Merge pull request rust-lang/nomicon#254 from mdaverde/ml/adds-compiler-err-lifetimes

## reference

9 commits in f02b09eb6e8af340ad1256a54adb7aae2ff3163e..361367c126290ac17cb4089f8d38fd8b2ac43f98
2021-01-22 01:53:02 -0800 to 2021-02-15 09:58:13 -0800
- Define turbofish in the glossary (rust-lang/reference#964)
- Remove enum variant expr (rust-lang/reference#963)
- One sentence is one line src/expressions/* (rust-lang/reference#962)
- Referencify bool type (rust-lang/reference#940)
- Fix typo in type cast expression table (rust-lang/reference#959)
- Define rust (rust-lang/reference#953)
- Remove "Memory Ownership" chapter (rust-lang/reference#952)
- Added setting nightly as a requirement for running tests (rust-lang/reference#955)
- Refactored build steps for better readability (rust-lang/reference#936)

## book

13 commits in e724bd826580ff95df48a8533af7dec1080693d4..db5e8a5105aa22979490dce30e33b68d8645761d
2021-01-20 08:19:49 -0600 to 2021-02-12 16:58:20 -0500
- Update to Rust 1.50
- Fix issue rust-lang/book#2574 - Improve the explanation about the behaviour of `read_line`. (rust-lang/book#2575)
- closures: replace "is called" with "is defined" (rust-lang/book#2556)
- Minor clarification: types -> values in ch16-04 (rust-lang/book#2587)
- fixed hidden code listing (rust-lang/book#2610)
- Merge remote-tracking branch 'origin/pr/2604'
-  (rust-lang/book#2601)
- Merge remote-tracking branch 'origin/pr/2589'
- Fix text wrapping
- Some small rewordings I noticed while rereading just now
-  (rust-lang/book#2592)
- Removed 'of' between type alias in Ch 19-04. (rust-lang/book#2581)
- Merge remote-tracking branch 'origin/pr/2554'

## rust-by-example

2 commits in f633769acef68574427a6fae6c06f13bc2199573..551cc4bc8394feccea6acd21f86d9a4e1d2271a0
2021-01-13 20:58:25 -0300 to 2021-02-03 17:12:37 -0300
- remove // (rust-lang/rust-by-example#1409)
- Update arc.md (rust-lang/rust-by-example#1406)

## edition-guide

3 commits in b91a9a881ee007c12e74e844460ec407cf07a50f..1da3c411f17adb1ba5de1683bb6acee83362b54a
2020-11-02 11:02:03 -0600 to 2021-02-16 16:46:40 -0800
- Update link for no_std. (rust-lang/edition-guide#231)
- Add git link to the source. (rust-lang/edition-guide#228)
- Update musl libc link (rust-lang/edition-guide#230)

## embedded-book

1 commits in ceec19e873be87c6ee5666b030c6bb612f889a96..4cf7981696a85c3e633076c6401611bd3f6346c4
2021-01-03 13:13:10 +0000 to 2021-02-11 10:55:22 +0000
- Fix installing dateutil since it is now a dependency of the GHP import script  (rust-embedded/book#282)
joeljpresent pushed a commit to joeljpresent/rust-book-fr that referenced this issue Apr 13, 2021
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 16, 2022
… r=Dylan-DPC

Improve the explanation about the behaviour of read_line

Close issue like rust-lang/book#2574
@femtoeu
Copy link

femtoeu commented Sep 1, 2022

Has that been changed? Because now, it overwrites the string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants