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 7146494 commit a1de5caCopy full SHA for a1de5ca
rust/src/types.rs
@@ -691,6 +691,41 @@ impl Drop for TypeBuilder {
691
//////////
692
// Type
693
694
+pub trait AbstractType {
695
+ fn resolve_type() -> Ref<Type>;
696
+}
697
+
698
+macro_rules! abstract_type {
699
+ ($($t:ty => $e:expr),+) => {
700
+ $(
701
+ impl AbstractType for $t {
702
+ fn resolve_type() -> Ref<Type> {
703
+ $e
704
+ }
705
706
+ )+
707
708
709
710
+abstract_type! {
711
+ u8 => Type::int(1, false),
712
+ u16 => Type::int(2, false),
713
+ u32 => Type::int(4, false),
714
+ u64 => Type::int(8, false),
715
+ i8 => Type::int(1, true),
716
+ i16 => Type::int(2, true),
717
+ i32 => Type::int(4, true),
718
+ i64 => Type::int(8, true),
719
+ f32 => Type::float(4),
720
+ f64 => Type::float(8)
721
722
723
+impl<T: AbstractType, const N: usize> AbstractType for [T; N] {
724
725
+ Type::array(&T::resolve_type(), N as u64)
726
727
728
729
#[repr(transparent)]
730
pub struct Type {
731
pub(crate) handle: *mut BNType,
0 commit comments