Expand description
High-level ALTREP data traits.
These traits let you implement ALTREP behavior using &self methods instead of
raw SEXP callbacks. The library provides blanket implementations that handle
the SEXP extraction automatically.
§Quick Start
For common types, just use them directly:
ⓘ
// Vec<i32> already implements AltIntegerData
let altrep = create_altinteger(vec![1, 2, 3, 4, 5]);For custom types, implement the relevant trait:
ⓘ
struct Fibonacci { len: usize }
impl AltrepLen for Fibonacci {
fn len(&self) -> usize { self.len }
}
impl AltIntegerData for Fibonacci {
fn elt(&self, i: usize) -> i32 {
// Compute fibonacci(i)
unimplemented!()
}
}For simple field-based types, the Altrep* derive macros provide a shorter path:
they auto-implement AltrepLen and the matching Alt*Data trait, and can
optionally call the low-level impl_alt*_from_data! helpers.
Re-exports§
pub use core::AltrepDataptr;pub use core::AltrepExtract;pub use core::AltrepExtractSubset;pub use core::AltrepLen;pub use core::AltrepSerialize;pub use core::InferBase;pub use core::Logical;pub use core::Sortedness;pub use core::materialize_altrep_data2;pub use iter::*;pub use stream::*;pub use traits::*;
Modules§
- builtins 🔒
- Built-in ALTREP data implementations for standard Rust types.
- core 🔒
- Core ALTREP data traits and helpers.
- iter 🔒
- Iterator-backed ALTREP data types.
- macros
- Helper macros for implementing ALTREP data traits.
Convenience macros for implementing
InferBase. - stream 🔒
- Streaming ALTREP data backed by chunk-cached reader closures.
- traits 🔒
- Per-family ALTREP data traits.