MCPcopy Index your code
hub / github.com/RustPython/RustPython / readline

Method readline

crates/vm/src/readline.rs:49–63  ·  view source on GitHub ↗
(&mut self, prompt: &str)

Source from the content-addressed store, hash-verified

47 }
48
49 pub fn readline(&mut self, prompt: &str) -> ReadlineResult {
50 use std::io::prelude::*;
51 print!("{prompt}");
52 if let Err(e) = io::stdout().flush() {
53 return ReadlineResult::Io(e);
54 }
55
56 let next_line = io::stdin().lock().lines().next();
57 match next_line {
58 Some(Ok(line)) => ReadlineResult::Line(line),
59 None => ReadlineResult::Eof,
60 Some(Err(e)) if e.kind() == io::ErrorKind::Interrupted => ReadlineResult::Interrupt,
61 Some(Err(e)) => ReadlineResult::Io(e),
62 }
63 }
64 }
65}
66

Callers

nothing calls this directly

Calls 6

trim_end_matchesMethod · 0.80
OtherClass · 0.50
flushMethod · 0.45
nextMethod · 0.45
lockMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected