When I try to compile the following code, I always encounter the trait bound `Condition<Left, Right, { Left::TYPE_SIZE > Right::TYPE_SIZE }>: IDataType` is not satisfied
use std::marker::PhantomData;
trait IDataType {
const TYPE_SIZE: usize;
type DataType: IDataType;
}
struct Condition<Left: IDataType, Right: IDataType, const condition: bool> {
left: PhantomData<Left>,
right: PhantomData<Right>,
}
impl<Left: IDataType, Right: IDataType> IDataType for Condition<Left, Right, true> {
const TYPE_SIZE: usize = Left::TYPE_SIZE;
type DataType = Left::DataType;
}
impl<Left: IDataType, Right: IDataType> IDataType for Condition<Left, Right, false> {
const TYPE_SIZE: usize = Right::TYPE_SIZE;
type DataType = Right::DataType;
}
struct MaxSizeType<Left: IDataType, Right: IDataType> {
left: PhantomData<Left>,
right: PhantomData<Right>,
}
impl<Left: IDataType, Right: IDataType> IDataType for MaxSizeType<Left, Right> {
const TYPE_SIZE: usize = 0;
type DataType = <Condition<Left, Right, { Left::TYPE_SIZE > Right::TYPE_SIZE }> as IDataType>::DataType;
}