mod private
{
use crate::*;
use core::
{
ops::{ Deref },
marker::PhantomData,
fmt,
};
#[ repr( transparent ) ]
#[ derive( Clone, Copy ) ]
pub struct AsTable< 'table, Table, RowKey, Row, CellKey>
(
&'table Table,
::core::marker::PhantomData
<(
&'table (),
fn() -> ( &'table RowKey, Row, &'table CellKey ),
)>,
)
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
;
impl< 'table, Table, RowKey, Row, CellKey>
AsTable< 'table, Table, RowKey, Row, CellKey>
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
{
pub fn new( src : &'table Table ) -> Self
{
Self( src, Default::default() )
}
}
impl< 'table, Table, RowKey, Row, CellKey> AsRef< Table >
for AsTable< 'table, Table, RowKey, Row, CellKey>
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
{
fn as_ref( &self ) -> &Table
{
&self.0
}
}
impl< 'table, Table, RowKey, Row, CellKey> Deref
for AsTable< 'table, Table, RowKey, Row, CellKey>
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
{
type Target = Table;
fn deref( &self ) -> &Self::Target
{
&self.0
}
}
impl< 'table, Table, RowKey, Row, CellKey> From< &'table Table >
for AsTable< 'table, Table, RowKey, Row, CellKey>
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
{
fn from( table : &'table Table ) -> Self
{
AsTable( table, PhantomData )
}
}
impl< 'table, Table, RowKey, Row, CellKey> fmt::Debug
for AsTable< 'table, Table, RowKey, Row, CellKey>
where
Table : fmt::Debug,
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
{
fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result
{
f
.debug_struct( "AsTable" )
.field( "0", &self.0 )
.finish()
}
}
pub trait IntoAsTable
{
type Table;
type RowKey : table::RowKey;
type Row : Cells< Self::CellKey >;
type CellKey : table::CellKey + ?Sized;
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >;
}
impl< 'table, Table, RowKey, Row, CellKey> IntoAsTable
for AsTable< 'table, Table, RowKey, Row, CellKey>
where
RowKey : table::RowKey,
Row : Cells< CellKey >,
CellKey : table::CellKey + ?Sized,
Self : Copy,
{
type Table = Table;
type RowKey = RowKey;
type Row = Row;
type CellKey = CellKey;
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >
{
*self
}
}
}
#[ allow( unused_imports ) ]
pub use own::*;
#[ allow( unused_imports ) ]
pub mod own
{
use super::*;
#[ doc( inline ) ]
pub use orphan::*;
}
#[ allow( unused_imports ) ]
pub mod orphan
{
use super::*;
#[ doc( inline ) ]
pub use exposed::*;
}
#[ allow( unused_imports ) ]
pub mod exposed
{
use super::*;
#[ doc( inline ) ]
pub use private::
{
AsTable,
IntoAsTable,
};
}
#[ allow( unused_imports ) ]
pub mod prelude
{
use super::*;
}