use crate::rational_sequences::{RationalSequence, rational_sequence_reduce};
use alloc::vec;
use alloc::vec::Vec;
impl<T: Eq> RationalSequence<T> {
pub const fn from_vec(non_repeating: Vec<T>) -> Self {
Self {
non_repeating,
repeating: vec![],
}
}
pub fn from_vecs(mut non_repeating: Vec<T>, mut repeating: Vec<T>) -> Self {
rational_sequence_reduce(&mut non_repeating, &mut repeating);
Self {
non_repeating,
repeating,
}
}
#[allow(clippy::missing_const_for_fn)] pub fn into_vecs(self) -> (Vec<T>, Vec<T>) {
(self.non_repeating, self.repeating)
}
#[allow(clippy::missing_const_for_fn)]
pub fn slices_ref(&self) -> (&[T], &[T]) {
(&self.non_repeating, &self.repeating)
}
}
impl<T: Clone + Eq> RationalSequence<T> {
pub fn from_slice(non_repeating: &[T]) -> Self {
Self {
non_repeating: non_repeating.to_vec(),
repeating: vec![],
}
}
pub fn from_slices(non_repeating: &[T], repeating: &[T]) -> Self {
let mut non_repeating = non_repeating.to_vec();
let mut repeating = repeating.to_vec();
rational_sequence_reduce(&mut non_repeating, &mut repeating);
Self {
non_repeating,
repeating,
}
}
pub fn to_vecs(&self) -> (Vec<T>, Vec<T>) {
(self.non_repeating.clone(), self.repeating.clone())
}
}