use crate::parser::Function;
#[derive(Debug, Clone, PartialEq)]
pub enum Operation {
Function(Function),
Resize {
cols: usize,
rows: usize,
},
}
impl From<Function> for Operation {
fn from(function: Function) -> Self {
Self::Function(function)
}
}
pub struct Single;
pub struct Sequence;
pub trait IntoOperations<Kind> {
type Iter: Iterator<Item: Into<Operation>>;
fn into_operations(self) -> Self::Iter;
}
impl<T: Into<Operation>> IntoOperations<Single> for T {
type Iter = std::iter::Once<T>;
fn into_operations(self) -> Self::Iter {
std::iter::once(self)
}
}
impl<I> IntoOperations<Sequence> for I
where
I: IntoIterator,
I::Item: Into<Operation>,
{
type Iter = I::IntoIter;
fn into_operations(self) -> Self::Iter {
self.into_iter()
}
}