Expand description
This module defines a types to encode an IF test within the type system.
The idea behind this concept is to match the condition, which is a type, with the structure the test is implemented for. This allows for a basic test similar to the following
let result = std::any::TypeId::of::<i32>() == std::any::TypeId::of::<i32>();
if result {
// Condition matched
} else {
// Condition failed to match
}§Example
use ct_utils::prelude::*;
// Trait to negate the signed-ness of a specific integer.
trait DeSignature<Target> {
type Result: ?Sized;
}
impl<Target> DeSignature<Target> for i32 {
// Depending on Target, CTIf::Path will become signed or unsigned.
// Result will receive the type contained by CTIf::Path.
type Result = <IfCheck<i32> as CTIf<Target, u32, i32>>::Path;
}§Notes
Structs§
- IfCheck
- Actual type used to perform an IF check through the type system.