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()
}
}