Skip to content

Commit

Permalink
Derive NewtypeCast and SubtypeCast for Var and Lit
Browse files Browse the repository at this point in the history
  • Loading branch information
jix committed Aug 4, 2024
1 parent 72cfdd9 commit fbd16f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ir/src/var.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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 }, <Lit as Id>::BaseId>);

/// Ensure that there is an even number of literals
Expand Down

0 comments on commit fbd16f8

Please sign in to comment.