Skip to main content

rint

Macro rint 

Source
rint!() { /* proc-macro */ }
Expand description

Generate RInt type from value range, auto select RRxx value type

  • full form rint!(MIN..=MAX, default = DEFAULT, step = STEP, bits = BITS), MIN and MAX is required, others is optional
  • range MIN..=MAX is same as `MIN..MAX+1``
  • if default not setted, then is MIN
  • if step not setted, then is 1, step must >= 1, and must ensure MIN % STEP == 0 && MAX % STEP == 0 && DEFAULT % STEP == 0
  • if bits not setted, then is ((MAX - MIN) / STEP).bit_width()
rint!(-10..=100) // RInt<u7, RRI8<-10, 100>>
rint!(-10..=100, default = 3) // RInt<u7, RRI8<-10, 100, 3>>
rint!(-10..=100, default = 20, step = 10) // RInt<u4, RRI8<-10, 100, 20, 10>>
rint!(3..50, default = 20) // RInt<u6, RRU8<3, 49, 20>>
rint!(3..50, default = 20, bits = 6) // RInt<u7, RRU8<3, 49, 20>>