add IntTypeTrait::literal utility function

This commit is contained in:
Jacob Lifshay 2024-07-21 20:45:36 -07:00
parent 8ca0cd56c4
commit bdfa18e11d
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c

View file

@ -887,6 +887,15 @@ pub trait IntTypeTrait:
CanonicalType = DynSIntType,
CanonicalValue = DynSInt,
>;
fn literal(self, value: impl Into<BigInt>) -> Expr<IntValue<Self>>
where
Self: IntTypeTrait<
CanonicalType = DynIntType<<Self as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<Self as IntTypeTrait>::Signed>,
>,
{
IntValue::with_type(self, value).to_expr()
}
fn from_width_unchecked(width: usize) -> Self;
fn width(self) -> usize;
fn as_same_width_uint(self) -> Self::SameWidthUInt;