Term::read_line() allows the delimiting newline to be printed to the terminal, even though it is omitted from the returned String. This is the same as the documented behaviour of BufRead::read_line(), which Term::read_line() ends up calling.
The implementation of Term::read_line_initial_text() is not consistent with this. In this case, the newline is not printed to the terminal.
use console::Term;
fn main() {
let term = Term::stderr();
println!("Enter ten lines. The final five will have initial text");
for _ in 1..6 {
term.read_line().unwrap();
}
for _ in 6..11 {
term.read_line_initial_text("Inital text ").unwrap();
}
}
After I run the above and enter the numbers 1 to 10, my terminal looks like this:
Enter ten lines. The final five will have initial text
1
2
3
4
5
Inital text 6Inital text 7Inital text 8Inital text 9Inital text 10$