From bdfa18e11d896af8b47dd2d9acba6fbd291c74c7 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 21 Jul 2024 20:45:36 -0700 Subject: [PATCH] add IntTypeTrait::literal utility function --- crates/fayalite/src/int.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/fayalite/src/int.rs b/crates/fayalite/src/int.rs index 4f31480..d6f4cfa 100644 --- a/crates/fayalite/src/int.rs +++ b/crates/fayalite/src/int.rs @@ -887,6 +887,15 @@ pub trait IntTypeTrait: CanonicalType = DynSIntType, CanonicalValue = DynSInt, >; + fn literal(self, value: impl Into) -> Expr> + where + Self: IntTypeTrait< + CanonicalType = DynIntType<::Signed>, + CanonicalValue = DynInt<::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;