1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::io;
use std::io::prelude::*;
pub fn read_line() -> io::Result<String> {
let stdin = io::stdin();
let handle = &mut stdin.lock();
let mut buf = String::new();
let _bytes = handle.read_line( &mut buf)?;
buf.pop();
Ok(buf)
}
pub fn print_str( s: &str) -> io::Result<()> {
let stdout = io::stdout();
let handle = &mut stdout.lock();
handle.write_all(s.as_bytes())?;
Ok(())
}
pub fn print_string( s: &String) -> io::Result<()> {
let stdout = io::stdout();
let handle = &mut stdout.lock();
handle.write_all(s.as_bytes())?;
Ok(())
}
pub fn stdout_flush() -> io::Result<()> {
let stdout = io::stdout();
let handle = &mut stdout.lock();
handle.flush()?;
Ok(())
}