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
use super::Repl;
use crate::LangInterface;
pub struct ReplIter<L: LangInterface> {
repl: Repl<L>,
color: crate::Color,
}
impl<L: LangInterface> ReplIter<L> {
pub fn new(repl: Repl<L>, color: crate::Color) -> Self {
Self { repl, color }
}
pub fn set_exit_keyword(&mut self, exit_keyword: &'static str) {
self.repl.set_exit_keyword(exit_keyword)
}
pub fn set_clear_keyword(&mut self, clear_keyword: &'static str) {
self.repl.set_clear_keyword(clear_keyword)
}
}
impl<L: LangInterface> Repl<L> {
pub fn iter(self, color: crate::Color) -> ReplIter<L> {
ReplIter::new(self, color)
}
}
impl<L: LangInterface> Iterator for ReplIter<L> {
type Item = String;
fn next(&mut self) -> Option<Self::Item> {
self.repl.next(self.color).ok()
}
}