Skip to content

Releases: kelpsyberry/proc-bitfield

v0.4.0

05 Apr 18:58
8fb8aae
Compare
Choose a tag to compare
  • BREAKING: Changed the default behavior of unsafe conversions to mark the accessor as unsafe; the old behavior (safe accessor that performs an unsafe conversion) can be obtained by adding a ! suffix to the attribute name, i.e. unsafe_get! T
  • Added field conversions through functions with get_fn, set_fn, unsafe_get_fn, unsafe_set_fn, try_get_fn, try_set_fn, unwrap_get_fn and unwrap_set_fn
  • Made the ConvRaw derive implement bool conversions for enums with only two variants with discriminants 0 and 1 (in any order)
  • Changes to the BitRange<T> and Bit traits:
    • Renamed and split the BitRange<T> trait, into Bits<T>, WithBits<T> and SetBits<T>
    • Split the Bit trait into Bit, WithBit and SetBit
    • Bits<T> and Bit read from a bitfield
    • With* traits return a changed version of the bitfield
    • Set* traits modify the bitfield in-place
  • Changed the implementations of UnsafeFrom<T> and UnsafeInto<T> so that either From<T> or Into<T> automatically implement both
    • Specifically, UnsafeFrom<U> for T now gets implemented if U: Into<T> (implied by T: From<U>), and UnsafeInto<U> for T gets implemented if U: UnsafeFrom<T>
  • Added built-in *Bits and *Bit implementations to use integer arrays as field and storage types, and to use unsized integer slices as storage types (only in the *bits! macros)

v0.3.1

23 Jan 20:12
97a9772
Compare
Choose a tag to compare
  • Added bits!, with_bits! and set_bits! as alternatives to bitfield! to operate on raw "bitfield storage" values without declaring a bitfield struct
  • Clarified BitRange's expected behavior in the documentation

v0.3.0

30 Jul 12:45
01e2e9c
Compare
Choose a tag to compare
  • Added unwrap_get/unwrap_set/unwrap_both/unwrap as alternatives to the try_* field type conversions that also unwrap the Results
  • Added a new derive macro named ConvRaw for automatic fallible enum conversions to and from integer types; this allows much easier usage of enums as bitfield fields
  • Added a new derive macro named UnwrapBitRange to add an automatic implementation of BitRange<T> to any integer types that can be converted to (fallibly) and from (infallibly) T, unwrapping on reads
  • Fixed an edge case in the default BitRange implementation for signed storage types, and expanded the default implementations