use core::fmt;
use std::fmt::{Debug, Display};
use crate::PrimInt;
#[derive(PartialEq, Eq, Hash, Clone, Default)]
pub struct RowCol<T: PrimInt> {
row: T,
col: T,
}
impl<T: PrimInt> RowCol<T> {
pub fn new(row: T, col: T) -> Self {
Self { row, col }
}
pub fn inc_row(&mut self, x: T) {
self.row += x;
}
pub fn inc_col(&mut self, x: T) {
self.col += x;
}
pub fn row(&self) -> T {
self.row
}
pub fn col(&self) -> T {
self.col
}
}
impl<T: PrimInt> Debug for RowCol<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RowCol")
.field("row", &self.row)
.field("col", &self.col)
.finish()
}
}
impl<T: PrimInt + Display> Display for RowCol<T> {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!()
}
}
mod impl_receivers {
use super::super::building;
use crate::PrimInt;
use building::bottom_up;
use building::top_down;
impl<T: PrimInt> top_down::CreateBuilder for super::RowCol<T> {
fn create() -> Self {
Self {
row: num::zero(),
col: num::zero(),
}
}
}
impl<T: PrimInt> bottom_up::CreateBuilder for super::RowCol<T> {
fn create() -> Self {
Self {
row: num::zero(),
col: num::zero(),
}
}
}
impl<IdN, T: PrimInt> top_down::ReceiveParent<IdN, Self> for super::RowCol<T> {
fn push(self, _parent: IdN) -> Self {
self
}
}
impl<IdN, T: PrimInt> bottom_up::ReceiveNode<IdN, Self> for super::RowCol<T> {
fn push(self, _node: IdN) -> Self {
self
}
}
impl<IdN, T: PrimInt> bottom_up::SetRoot<IdN, Self> for super::RowCol<T> {
fn set_root(self, _root: IdN) -> Self {
self
}
}
impl<IdN, T: PrimInt> top_down::SetNode<IdN, Self> for super::RowCol<T> {
fn set_node(self, _node: IdN) -> Self {
self
}
}
impl<T: PrimInt> top_down::ReceiveDirName<Self> for super::RowCol<T> {
fn push(self, _dir_name: &str) -> Self {
self
}
}
impl<T: PrimInt> bottom_up::ReceiveDirName<Self> for super::RowCol<T> {
fn push(self, _dir_name: &str) -> Self {
self
}
}
impl<T: PrimInt> top_down::SetFileName<Self> for super::RowCol<T> {
fn set_file_name(self, _file_name: &str) -> Self {
self
}
}
impl<Idx, T: PrimInt> top_down::ReceiveIdx<Idx, Self> for super::RowCol<T> {
fn push(self, _idx: Idx) -> Self {
self
}
}
impl<Idx, T: PrimInt> bottom_up::ReceiveIdx<Idx, Self> for super::RowCol<T> {
fn push(self, _idx: Idx) -> Self {
self
}
}
impl<Idx, T: PrimInt> top_down::ReceiveIdxNoSpace<Idx, Self> for super::RowCol<T> {
fn push(self, _idx: Idx) -> Self {
self
}
}
impl<T: PrimInt, IdO> top_down::ReceiveOffset<IdO, Self> for super::RowCol<T> {
fn push(self, _offset: IdO) -> Self {
self
}
}
impl<T: PrimInt, IdO> bottom_up::ReceiveOffset<IdO, Self> for super::RowCol<T> {
fn push(self, _offset: IdO) -> Self {
self
}
}
impl<T: PrimInt> building::ReceiveRows<T, Self> for super::RowCol<T> {
fn push(mut self, row: T) -> Self {
self.row += row;
self
}
}
impl<T: PrimInt> building::ReceiveColumns<T, Self> for super::RowCol<T> {
fn push(mut self, col: T) -> Self {
self.col += col;
self
}
}
impl<T: PrimInt, IdO> building::SetLen<IdO, Self> for super::RowCol<T> {
fn set(self, _len: IdO) -> Self {
self
}
}
impl<T: PrimInt> top_down::FileSysReceiver for super::RowCol<T> {
type InFile<O> = Self;
}
impl<T: PrimInt> building::Transition<super::RowCol<T>> for super::RowCol<T> {
fn transit(self) -> super::RowCol<T> {
self
}
}
}