We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
AbstractType
1 parent 7064468 commit 466fe3dCopy full SHA for 466fe3d
rust/src/types.rs
@@ -695,6 +695,41 @@ impl Drop for TypeBuilder {
695
//////////
696
// Type
697
698
+pub trait AbstractType {
699
+ fn resolve_type() -> Ref<Type>;
700
+}
701
+
702
+macro_rules! abstract_type {
703
+ ($($t:ty => $e:expr),+) => {
704
+ $(
705
+ impl AbstractType for $t {
706
+ fn resolve_type() -> Ref<Type> {
707
+ $e
708
+ }
709
710
+ )+
711
712
713
714
+abstract_type! {
715
+ u8 => Type::int(1, false),
716
+ u16 => Type::int(2, false),
717
+ u32 => Type::int(4, false),
718
+ u64 => Type::int(8, false),
719
+ i8 => Type::int(1, true),
720
+ i16 => Type::int(2, true),
721
+ i32 => Type::int(4, true),
722
+ i64 => Type::int(8, true),
723
+ f32 => Type::float(4),
724
+ f64 => Type::float(8)
725
726
727
+impl<T: AbstractType, const N: usize> AbstractType for [T; N] {
728
729
+ Type::array(&T::resolve_type(), N as u64)
730
731
732
733
#[repr(transparent)]
734
pub struct Type {
735
pub(crate) handle: *mut BNType,
0 commit comments