use core::fmt;
use core::marker::PhantomData;
use crate::iso::witness::algebra_iso::AlgebraIso;
use crate::iso::witness::division_algebra_iso::DivisionAlgebraIso;
use crate::iso::witness::field_iso::FieldIso;
use crate::iso::witness::group_iso::GroupIso;
use crate::iso::witness::iso::Iso;
use crate::iso::witness::ring_iso::RingIso;
use crate::{Algebra, DivisionAlgebra, Field, Group, Ring};
pub struct StandardIso<S, T> {
_marker_s: PhantomData<fn() -> S>,
_marker_t: PhantomData<fn() -> T>,
}
impl<S, T> StandardIso<S, T> {
#[inline]
pub const fn new() -> Self {
StandardIso {
_marker_s: PhantomData,
_marker_t: PhantomData,
}
}
}
impl<S, T> Clone for StandardIso<S, T> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<S, T> Copy for StandardIso<S, T> {}
impl<S, T> Default for StandardIso<S, T> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<S, T> fmt::Debug for StandardIso<S, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("StandardIso")
}
}
impl<S, T> Iso<S, T> for StandardIso<S, T>
where
S: From<T>,
T: From<S>,
{
#[inline]
fn to_target(s: S) -> T {
T::from(s)
}
#[inline]
fn to_source(t: T) -> S {
S::from(t)
}
}
impl<S, T> GroupIso<S, T> for StandardIso<S, T>
where
S: Group + From<T>,
T: Group + From<S>,
{
}
impl<S, T> RingIso<S, T> for StandardIso<S, T>
where
S: Ring + From<T>,
T: Ring + From<S>,
{
}
impl<S, T> FieldIso<S, T> for StandardIso<S, T>
where
S: Field + From<T>,
T: Field + From<S>,
{
}
impl<S, T, R> AlgebraIso<S, T, R> for StandardIso<S, T>
where
S: Algebra<R> + From<T>,
T: Algebra<R> + From<S>,
R: Ring,
{
}
impl<S, T, R> DivisionAlgebraIso<S, T, R> for StandardIso<S, T>
where
S: DivisionAlgebra<R> + From<T>,
T: DivisionAlgebra<R> + From<S>,
R: Field,
{
}