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

There is a bug with print! #38881

Closed
3442853561 opened this issue Jan 6, 2017 · 5 comments
Closed

There is a bug with print! #38881

3442853561 opened this issue Jan 6, 2017 · 5 comments

Comments

@3442853561
Copy link
Contributor

3442853561 commented Jan 6, 2017

The prompt message (with out line feed) can not be output before input.

use std::io;
fn main(){
    print!("test\ntest");
	let mut input = String::new();
        io::stdin()
            .read_line(&mut input)
            .expect("Failed to read line");
	println!("{:?}",input);
}

Screenshot

@steveklabnik
Copy link
Member

I don't think this is a bug. print! doesn't flush stdout like println! does, so until you do so, it won't get printed. Its docs explain this: https://doc.rust-lang.org/stable/std/macro.print.html

@alexcrichton
Copy link
Member

Ah yes I believe this is a dupe of #38710, so closing in favor of that.

@3442853561
Copy link
Contributor Author

@steveklabnik Thank you!

@steveklabnik
Copy link
Member

@alexcrichton did you mean a different issue? that one is about android...

@alexcrichton
Copy link
Member

Oops yes, #23818 is the link I intended

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

No branches or pull requests

3 participants