1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
#![no_std]
use core::{
fmt::{self, Formatter, Write},
ops::{Add, AddAssign, Sub, SubAssign},
};
const UNITS: &[u8] = &[b'K', b'M', b'G', b'T', b'P'];
macro_rules! get_bits_from_type_value {
($vis:vis, u8, U8, $val:expr) => {
#[cfg(any(all(feature = "u16", feature = "bits"), not(any(feature = "u16", feature = "u32", feature = "usize"))))]
get_bits_from_type_value!($vis, u16, U16, $val);
#[cfg(all(not(feature = "u16"), feature = "u32"))]
get_bits_from_type_value!($vis, u32, U32, $val);
#[cfg(all(not(feature = "u16"), not(feature = "u32"), feature = "usize"))]
get_bits_from_type_value!($vis, usize, USize, $val);
};
($vis:vis, $ty:ident, $name:ident, $val:expr $(, $feature:literal)?) => {
concat_idents::concat_idents!(bits_ident = Bits, $name {
/// Amount of bits, describing the size of this type
/// # Examples
/// ```
/// use anysize::*;
/// assert_eq!(BitsU8::BITS.get(), 1u16);
/// assert_eq!(BytesU32::BITS.get(), 8u32);
/// assert_eq!(WordsU32::BITS.get(), 32u32);
/// assert_eq!(ZWordsU8::BITS.get(), 512u16);
/// ```
/// Note: The type is at least 16bit
#[cfg(feature = "bits")]
$vis const BITS: bits_ident = bits_ident::new($val as $ty);
/// Amount of bits, describing the size of this type
/// # Examples
/// ```
/// use anysize::*;
/// assert_eq!(BitsU8::BITS, 1u8);
/// assert_eq!(BytesU32::BITS, 8u32);
/// assert_eq!(WordsU32::BITS, 32u32);
/// assert_eq!(ZWordsU8::BITS, 512u16);
/// ```
/// Note: The type is at least 16bit
#[cfg(not(feature = "bits"))]
$vis const BITS: $ty = $val as $ty;
});
}
}
/// For generating conversion functions between data types
#[allow(unused_macros)]
macro_rules! generate_type_conversion_fn {
{
$vis:vis $a_base_ident:ident ($a_bit_size:literal) => $b_base_ident:ident ($b_bit_size:literal) as $ident:ident {
$(#[feature($feature:literal)] $ty:ident as $name:ident),+$(,)?
}
} => {
$(
#[cfg(feature = $feature)]
#[cfg_attr(not(feature = $feature), allow(rust_analyzer::inactive_code))]
const _: () = {
concat_idents::concat_idents!(a = $a_base_ident, $name {
type $a_base_ident = a;
});
concat_idents::concat_idents!(b = $b_base_ident, $name {
type $b_base_ident = b;
});
concat_idents::concat_idents!(into_b = as_, $ident {
impl $a_base_ident {
/// Converts one kind of data size type into another
/// # Example
/// ```
/// use anysize::*;
/// let words = WordsU32::new(10);
/// let bytes = words.as_bytes();
/// assert_eq!(bytes.get(), 40);
/// let bits = bytes.as_bits();
/// assert_eq!(bits.get(), 320);
/// assert_eq!(words.as_bits().get(), bits.get());
/// ```
#[must_use]
$vis const fn into_b(self) -> $b_base_ident {
if $a_bit_size > $b_bit_size {
$b_base_ident::new(self.mul(($a_bit_size as u16 / $b_bit_size as u16) as $ty).get())
} else {
$b_base_ident::new(self.div_ceil((if ($b_bit_size as u16 / $a_bit_size as u16) > 256 { 1 } else { $b_bit_size / $a_bit_size }) as $ty).get())
}
}
}
impl Into<$b_base_ident> for $a_base_ident {
#[inline(always)]
fn into(self) -> $b_base_ident {
self.into_b()
}
}
});
};
)+
};
}
/// For generating conversion functions between inner types
macro_rules! generate_size_conversion_fn {
{
$vis:vis $base_ident:ident as $ident:ident {
$(#[features($feature_a:literal, $feature_b:literal)] $(#[pointer_size($ptr_size:literal)])? $a_ty:ident as $a_name:ident $cmp:tt $b_ty:ident as $b_name:ident),+$(,)?
}
} => {
$(
#[cfg(all(feature = $feature_a, feature = $feature_b$(, target_pointer_width = $ptr_size)?))]
#[cfg_attr(not(all(feature = $feature_a, feature = $feature_b$(, target_pointer_width = $ptr_size)?)), allow(rust_analyzer::inactive_code))]
const _: () = {
concat_idents::concat_idents!(a = $base_ident, $a_name {
type $a_name = a;
});
concat_idents::concat_idents!(b = $base_ident, $b_name {
type $b_name = b;
});
concat_idents::concat_idents!(into_b = as_, $b_ty {
impl $a_name {
/// Converts the size of an object
/// # Panics:
/// Will panic if value won't fit in new type
/// # Example:
/// ```
/// use anysize::*;
/// let bits = BitsU8::new(10);
/// let bits = bits.as_u32(); // Can't panic, because size_of::<u8>() < size_of::<u32>()
/// let bits = bits + BitsU32::new(100000);
/// // bits.as_u8(); Will panic here
/// ```
#[must_use]
#[inline(always)]
$vis const fn into_b(self) -> $b_name {
if 1 $cmp 0 {
assert!(self.get() <= $b_ty::MAX as $a_ty);
}
$b_name::new(self.get() as $b_ty)
}
}
impl Into<$b_name> for $a_name {
#[inline(always)]
fn into(self) -> $b_name {
self.into_b()
}
}
});
concat_idents::concat_idents!(into_a = as_, $a_ty {
impl $b_name {
/// Converts the size of an object
/// # Panics:
/// Will panic if value won't fit in new type
/// # Example:
/// ```
/// use anysize::*;
/// let bits = BitsU8::new(10);
/// let bits = bits.as_u32(); // Can't panic, because size_of::<u8>() < size_of::<u32>()
/// let bits = bits + BitsU32::new(100000);
/// // bits.as_u8(); Would panic here
/// ```
#[must_use]
#[inline(always)]
$vis const fn into_a(self) -> $a_name {
if 0 $cmp 1 {
assert!(self.get() <= $a_ty::MAX as $b_ty);
}
$a_name::new(self.get() as $a_ty)
}
}
impl Into<$a_name> for $b_name {
#[inline(always)]
fn into(self) -> $a_name {
self.into_a()
}
}
});
};)+
};
}
/// Generating the type itself + some basic functionality with itself
macro_rules! generate_base {
{
$words:ident = $bit_size:literal;
$vis:vis struct $base_ident:ident: $(#[feature($feature:literal)] $var_ty:ident as $var_ident:ident),+$(,)?
} => {
$(
#[cfg(feature = $feature)]
#[cfg_attr(not(feature = $feature), allow(rust_analyzer::inactive_code))]
concat_idents::concat_idents!(struct_ident = $base_ident, $var_ident {
/// Const zero cost abstraction to add differenciate data size types.
/// # Examples
/// ```
/// use anysize::*;
/// let bits = BitsU8::new(10);
/// assert_eq!(bits.get(), 10u8);
///
/// let bytes = BytesU8::new(2);
/// assert_eq!(bytes.get(), 2u8);
///
/// let words = WordsU8::of::<u128>();
/// assert_eq!(words.get(), 4);
///
/// // Sizes are equal to the suffix
/// assert_eq!(size_of::<BytesU8>(), size_of::<u8>());
/// assert_eq!(size_of::<BitsU32>(), size_of::<u32>());
/// assert_eq!(size_of::<WordsUSize>(), size_of::<usize>());
///
/// // Types are universally interchangeable
/// let bits = BitsU8::new(16);
/// assert_eq!(bits.get(), 16);
/// let bytes = bits.as_bytes();
/// assert_eq!(bytes.get(), 2);
/// // A.as_B asks the question: "How many B do I need to fit A"
/// // So you need for example 2 bytes for 12 bits
/// let words = bytes.as_words();
/// assert_eq!(words.get(), 1);
/// let words_as_bits = words.as_bits();
/// assert_eq!(words_as_bits.get(), 32);
/// assert_ne!(bits, words_as_bits);
///
/// // Sizes are also universally interchangeable
/// let bits = BitsU8::new(200);
/// assert_eq!(bits.get(), 200);
/// // bits + BitsU8::new(100) would panic, because 200 + 100 > u8::MAX
/// let mut bits = bits.as_u32();
/// assert_eq!(bits.get(), 200);
/// bits += BitsU32::new(100);
/// assert_eq!(bits.get(), 300);
///
/// // Get
/// assert_eq!(WordsU8::BITS, BitsU16::new(32));
/// let bytes = BytesUSize::of::<u32>();
/// assert_eq!(bytes.get(), size_of::<u32>());
///
/// // Math
/// assert_eq!(BytesU8::new(2) + BytesU8::new(6), BytesU8::new(8));
/// ```
#[repr(transparent)]
#[derive(Clone,Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
$vis struct struct_ident {
pub(self) inner: $var_ty
}
impl Default for struct_ident {
#[inline(always)]
fn default() -> Self {
Self::ZERO
}
}
impl struct_ident {
get_bits_from_type_value!($vis, $var_ty, $var_ident, $bit_size);
$vis const ZERO: Self = Self::new(0);
$vis const ONE: Self = Self::new(1);
$vis const MAX: Self = Self::new($var_ty::MAX);
/// Will create a new instance of the given type
/// # Examples
/// ```
/// use anysize::*;
/// let bytes = BytesU32::new(10);
/// assert_eq!(bytes.get(), 10);
/// ```
#[must_use]
#[inline(always)]
$vis const fn new($words: $var_ty) -> Self {
Self { inner: $words }
}
/// Gets the value as integer
/// # Examples
/// ```
/// use anysize::*;
/// let bytes = BytesU32::new(10);
/// assert_eq!(bytes.get(), 10);
/// ```
#[must_use]
#[inline(always)]
$vis const fn get(self) -> $var_ty {
self.inner
}
/// Creates new instance, depending on the size of a type
/// # Examples
/// ```
/// use anysize::*;
/// assert_eq!(BitsU32::of::<u128>().get(), 128);
/// assert_eq!(WordsU8::of::<u64>().get(), 2);
/// assert_eq!(BytesUSize::of::<isize>().get(), size_of::<isize>());
/// ```
#[must_use]
#[inline]
$vis const fn of<T>() -> Self {
let size = if $bit_size < 8 {
size_of::<T>() * ((8 / $bit_size) as usize)
} else if $bit_size == 8 {
size_of::<T>()
} else {
size_of::<T>().div_ceil(($bit_size / 8) as usize)
};
assert!(size <= $var_ty::MAX as usize);
Self::new(size as $var_ty)
}
/// Returns the next power of two
#[must_use]
#[inline(always)]
$vis const fn next_power_of_two(self) -> Self {
Self::new(self.inner.next_power_of_two())
}
/// Returns if the value is a power of two
#[must_use]
#[inline(always)]
$vis const fn is_power_of_two(self) -> bool {
self.inner.is_power_of_two()
}
/// Const addition
#[must_use]
#[inline(always)]
$vis const fn add(self, other: Self) -> Self {
Self::new(self.inner + other.inner)
}
/// Const subtraction
#[must_use]
#[inline(always)]
$vis const fn sub(self, other: Self) -> Self {
Self::new(self.inner - other.inner)
}
/// Const multiplication with integer
#[must_use]
#[inline(always)]
$vis const fn mul(self, other: $var_ty) -> Self {
Self::new(self.inner * other)
}
/// Const division with integer
#[must_use]
#[inline(always)]
$vis const fn div(self, other: $var_ty) -> Self {
Self::new(self.inner / other)
}
/// Const ceil rounding devision with integer
#[must_use]
#[inline(always)]
$vis const fn div_ceil(self, other: $var_ty) -> Self {
Self::new(self.inner.div_ceil(other))
}
/// Const eq
#[must_use]
#[inline(always)]
$vis const fn eq(self, other: Self) -> bool {
self.inner == other.inner
}
/// Const ne
#[must_use]
#[inline(always)]
$vis const fn ne(self, other: Self) -> bool {
self.inner != other.inner
}
/// Const gt
#[must_use]
#[inline(always)]
$vis const fn gt(self, other: Self) -> bool {
self.inner > other.inner
}
/// Const ge
#[must_use]
#[inline(always)]
$vis const fn ge(self, other: Self) -> bool {
self.inner >= other.inner
}
/// Const lt
#[must_use]
#[inline(always)]
$vis const fn lt(self, other: Self) -> bool {
self.inner < other.inner
}
/// Const le
#[must_use]
#[inline(always)]
$vis const fn le(self, other: Self) -> bool {
self.inner <= other.inner
}
/// Const min
#[must_use]
#[inline(always)]
$vis const fn min(self, other: Self) -> Self {
if self.lt(other) {
self
} else {
other
}
}
/// Const max
#[must_use]
#[inline(always)]
$vis const fn max(self, other: Self) -> Self {
if self.gt(other) {
self
} else {
other
}
}
/// Const clamp
#[must_use]
#[inline(always)]
$vis const fn clamp(self, min: Self, max: Self) -> Self {
assert!(min.le(max));
if self.le(min) {
min
} else if self.ge(max) {
max
} else {
self
}
}
}
impl Add for struct_ident {
type Output = Self;
#[inline(always)]
fn add(self, rhs: Self) -> Self::Output {
self.add(rhs)
}
}
impl AddAssign for struct_ident {
#[inline(always)]
fn add_assign(&mut self, rhs: Self) {
*self = self.add(rhs);
}
}
impl Sub for struct_ident {
type Output = Self;
#[inline(always)]
fn sub(self, rhs: Self) -> Self::Output {
self.sub(rhs)
}
}
impl SubAssign for struct_ident {
#[inline(always)]
fn sub_assign(&mut self, rhs: Self) {
*self = self.sub(rhs);
}
}
impl Into<$var_ty> for struct_ident {
#[inline(always)]
fn into(self) -> $var_ty {
self.get()
}
}
impl From<$var_ty> for struct_ident {
#[inline(always)]
fn from(value:$var_ty) -> struct_ident {
Self::new(value)
}
}
impl fmt::Binary for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::Binary::fmt(&self.inner, f)
}
}
impl fmt::UpperHex for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::Binary::fmt(&self.inner, f)
}
}
impl fmt::LowerHex for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::LowerHex::fmt(&self.inner, f)
}
}
impl fmt::Octal for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::Octal::fmt(&self.inner, f)
}
}
impl fmt::UpperExp for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::UpperExp::fmt(&self.inner, f)
}
}
impl fmt::LowerExp for struct_ident {
#[inline(always)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::LowerExp::fmt(&self.inner, f)
}
}
impl fmt::Display for struct_ident {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let mut integer = self.get();
let mut fraction = 0;
let mut unit: u8 = u8::MAX;
const ONE_K: $var_ty = 1024u16 as $var_ty;
if ONE_K > 0 {
while integer >= 1024u16 as $var_ty {
fraction *= 1024u16 as $var_ty;
fraction += integer % 1024u16 as $var_ty;
integer /= 1024u16 as $var_ty;
unit = unit.wrapping_add(1);
}
}
if f.sign_minus() {
write!(f, "-")?;
} else if f.sign_plus() {
write!(f, "+")?;
}
write!(f, "{integer}")?;
if unit != 255 {
let max_possible_decimals = (unit as usize + 1) * 4;
let required_decimals = f.precision().unwrap_or(2);
let decimals = max_possible_decimals.min(required_decimals);
if let Some(decimals_to_shave) = max_possible_decimals.checked_sub(required_decimals) {
for _ in 0..decimals_to_shave {
fraction /= 10;
if fraction == 0 {
break;
}
}
}
if fraction > 0 {
write!(f, ".{fraction:0decimals$}")?;
}
}
f.write_char(' ')?;
if unit < UNITS.len().min(u8::MAX as usize) as u8 {
f.write_char(UNITS[unit as usize] as char)?;
}
f.write_str(if integer == 1 && fraction == 0 {
&stringify!($words)[0..(stringify!($words).len() - 1)]
} else {
stringify!($words)
})
}
}
impl fmt::Debug for struct_ident {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.inner, f)?;
f.write_char(' ')?;
f.write_str(if self.inner == 1 {
&stringify!($words)[0..(stringify!($words).len() - 1)]
} else {
stringify!($words)
})
}
}
});
)+
};
}
macro_rules! generate {
($vis:vis $words:ident = $bit_size:literal as $name:ident $(, impl Into<$(#[feature($feature:literal)] $impl_ty:ident ($impl_bits:literal) as $impl_words:ident),+$(,)?>)*) => {
generate_base! {
$words = $bit_size;
$vis struct $name:
#[feature("u8")] u8 as U8,
#[feature("u16")] u16 as U16,
#[feature("u32")] u32 as U32,
#[feature("u64")] u64 as U64,
#[feature("u128")] u128 as U128,
#[feature("usize")] usize as USize,
}
generate_size_conversion_fn! {
$vis $name as $words {
#[features("u8", "usize")] u8 as U8 < usize as USize,
#[features("u8", "u16")] u8 as U8 < u16 as U16,
#[features("u8", "u32")] u8 as U8 < u32 as U32,
#[features("u8", "u64")] u8 as U8 < u64 as U64,
#[features("u8", "u128")] u8 as U8 < u128 as U128,
#[features("u16", "u32")] u16 as U16 < u32 as U32,
#[features("u16", "u64")] u16 as U16 < u64 as U64,
#[features("u16", "u128")] u16 as U16 < u128 as U128,
#[features("u32", "u64")] u32 as U32 < u64 as U64,
#[features("u32", "u128")] u32 as U32 < u128 as U128,
#[features("u64", "u128")] u64 as U64 < u128 as U128,
#[features("usize", "u16")] #[pointer_size("16")] usize as USize == u16 as U16,
#[features("usize", "u32")] #[pointer_size("16")] usize as USize < u32 as U32,
#[features("usize", "u64")] #[pointer_size("16")] usize as USize < u64 as U64,
#[features("usize", "u16")] #[pointer_size("32")] usize as USize > u16 as U16,
#[features("usize", "u32")] #[pointer_size("32")] usize as USize == u32 as U32,
#[features("usize", "u64")] #[pointer_size("32")] usize as USize < u64 as U64,
#[features("usize", "u16")] #[pointer_size("64")] usize as USize > u16 as U16,
#[features("usize", "u32")] #[pointer_size("64")] usize as USize > u32 as U32,
#[features("usize", "u64")] #[pointer_size("64")] usize as USize == u64 as U64,
#[features("usize", "u128")] usize as USize < u128 as U128,
}
}
$(
$(
#[cfg(feature = $feature)]
#[cfg_attr(not(feature = $feature), allow(rust_analyzer::inactive_code))]
generate_type_conversion_fn! {
$vis $name ($bit_size) => $impl_ty ($impl_bits) as $impl_words {
#[feature("u8")] u8 as U8,
#[feature("u16")] u16 as U16,
#[feature("u32")] u32 as U32,
#[feature("u64")] u64 as U64,
#[feature("u128")] u128 as U128,
#[feature("usize")] usize as USize,
}
}
)+
)?
};
}
#[cfg(feature = "bits")]
generate!(pub bits = 1 as Bits, impl Into<
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "bytes")]
generate!(pub bytes = 8 as Bytes, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "hwords")]
generate!(pub hwords = 16 as HWords, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "words")]
generate!(pub words = 32 as Words, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "dwords")]
generate!(pub dwords = 64 as DWords, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "qwords")]
generate!(pub qwords = 128 as QWords, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("ywords")] YWords (256) as ywords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "ywords")]
generate!(pub ywords = 256 as YWords, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("zwords")] ZWords (512) as zwords,
>);
#[cfg(feature = "zwords")]
generate!(pub zwords = 512 as ZWords, impl Into<
#[feature("bits")] Bits (1) as bits,
#[feature("bytes")] Bytes (8) as bytes,
#[feature("hwords")] HWords (16) as hwords,
#[feature("words")] Words (32) as words,
#[feature("dwords")] DWords (64) as dwords,
#[feature("qwords")] QWords (128) as qwords,
#[feature("ywords")] YWords (256) as ywords,
>);