Skip to main content

Module macros

Module macros 

Source
Expand description

§Internal Macros - Automates boilerplate Array implementations

Utilities to remove boilerplate when building Minarrow array types, trait impls, and enum dispatch. These macros keep array definitions small and consistent.

§Included macros

  • impl_numeric_array_constructors! - adds common constructors (new, with_capacity, from_slice) to “numeric-shaped” arrays that store data: Buffer<T> and an optional null_mask.
  • impl_masked_array! - implements the core [MaskedArray] trait for a given array type and element bound, including getters/setters, iterators, slicing (slice_clone), and null-mask handling.
  • impl_from_vec_primitive! - adds zero-copy builders (from_vec64, from_vec) for arrays backed by Vec64<T> (and friends).
  • match_array! - concise enum dispatch helper over [Array] variants; calls the same method on the active variant and returns a default otherwise.
  • impl_usize_conversions! - implements lossless usize conversions for integer offset/index types used across the crate.
  • impl_array_ref_deref! - generates AsRef, AsMut, Deref, DerefMut to expose the inner value buffer as slices, for generic or concrete arrays.
  • impl_arc_masked_array! - implements [MaskedArray] for Arc<Inner>, enabling clone-on-write mutation and making Arc arrays usable with view APIs.

§Notes

  • Macros assume Minarrow’s standard field layout (e.g., data, null_mask), and will not fit bespoke shapes without tweaks.
  • Safety docs generated by the macros apply to the produced methods (e.g. the *_unchecked paths). Use only when preconditions are guaranteed.
  • Feature gates (parallel_proc, views, etc.) are respected where relevant.