use crate::rational_sequences::RationalSequence;
use core::fmt::{Debug, Display, Formatter, Result, Write};
impl<T: Display + Eq> Display for RationalSequence<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
f.write_char('[')?;
let mut first = true;
for x in &self.non_repeating {
if first {
first = false;
} else {
f.write_str(", ")?;
}
Display::fmt(x, f)?;
}
if !self.repeating.is_empty() {
if !self.non_repeating.is_empty() {
f.write_str(", ")?;
}
f.write_char('[')?;
let mut first = true;
for x in &self.repeating {
if first {
first = false;
} else {
f.write_str(", ")?;
}
Display::fmt(x, f)?;
}
f.write_char(']')?;
}
f.write_char(']')
}
}
impl<T: Display + Eq> Debug for RationalSequence<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
Display::fmt(self, f)
}
}