Help with [E0599] when implementing trait

I also tried these:

  • Doesn't work (same (E0599) error) .... somehow doesn't like the _f_guard funciton even though it just returns true:
struct Guard<const U: bool>;
trait Protect {}
impl Protect for Guard<true> {}

impl <K: Hash + std::cmp::Eq, V, const C: usize> Index<&K> for FixedSizeHashMap <K, V, C>
 where
    Guard<{
        const fn _f_guard<const C: usize>() -> bool {
            true
        }
        _f_guard::<C>()
    }>: Protect,
{
   // ......
}
  • Doesnt work => (error expression is too complex and suggest I use a const fn):
impl <K: Hash + std::cmp::Eq, V, const C: usize> Index<&K> for FixedSizeHashMap <K, V, C>
 where
    Guard<{
       if !C <= 25013 {
            panic!("guard evaluated to false")
         }
        true    // <<========== Error expression is too complex
    }>: Protect,
{
   // ......
}
  • Works!!! =>
impl <K: Hash + std::cmp::Eq, V, const C: usize> FixedSizeHashMap <K, V, C>
 where
    Guard<{
        C <= 25013  /// << === Simple expression works
    }>: Protect,
{