fayalite 0.2.0

Hardware Description Language embedded in Rust, using FIRRTL's semantics
Documentation
// SPDX-License-Identifier: LGPL-3.0-or-later
// See Notices.txt for copyright information
use std::{fmt::Debug, hash::Hash};

mod sealed {
    pub trait Sealed {}
}

/// the only implementation is `ConstUsize<Self::VALUE>`
pub trait GenericConstUsize:
    sealed::Sealed + Copy + Ord + Hash + Default + Debug + 'static + Send + Sync
{
    const VALUE: usize;
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct ConstUsize<const VALUE: usize>;

impl<const VALUE: usize> Debug for ConstUsize<VALUE> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_tuple("ConstUsize").field(&Self::VALUE).finish()
    }
}

impl<const VALUE: usize> sealed::Sealed for ConstUsize<VALUE> {}

impl<const VALUE: usize> GenericConstUsize for ConstUsize<VALUE> {
    const VALUE: usize = VALUE;
}