From fbd16f8d68ac53e2f0befb63cbf08411b9d29a70 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sun, 4 Aug 2024 10:54:58 +0200 Subject: [PATCH] Derive NewtypeCast and SubtypeCast for Var and Lit --- ir/src/var.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ir/src/var.rs b/ir/src/var.rs index 8ebd53a..3ece5f7 100644 --- a/ir/src/var.rs +++ b/ir/src/var.rs @@ -1,5 +1,6 @@ //! Numeric identifiers for variables and Boolean literals +use imctk_derive::{NewtypeCast, SubtypeCast}; use imctk_ids::{GenericId, Id, Id32}; use std::{fmt::Debug, hash::Hash, ops}; @@ -18,12 +19,12 @@ use std::{fmt::Debug, hash::Hash, ops}; /// not the [`index`][`Self::index`]. The index of a literal is the same as the corresponding /// variable's [`index`][`Var::index`]. #[repr(transparent)] -#[derive(Id)] +#[derive(Id, SubtypeCast, NewtypeCast)] pub struct Lit(Id32); /// Numeric identifier for a variable. #[repr(transparent)] -#[derive(Id)] +#[derive(Id, SubtypeCast, NewtypeCast)] pub struct Var(GenericId<{ Lit::MAX_ID_INDEX / 2 }, ::BaseId>); /// Ensure that there is an even number of literals