cl-traits 0.1.0

Provides traits that describe collections
Documentation

Collection Traits (cl-traits)

Yet another library to provide traits that describe collections. This is a best-effort without GAT.

Many data structures have unique features that make it difficult or even impossible to create a single trait that fits all. That is why this crate provides a single method for each trait to achieve maximum flexibility and freedom.

Derives (WIP)

Derives are somewhat limited because they aggregate every single attribute, threfore, should be used with caution.

use cl_traits::*;

#[derive(WithLength)]
struct SomeCustomVector(Vec<i32>, Vec<i32>);

fn main() {
  let v = SomeCustomVector(vec![1, 2], vec![3, 4, 5, 6]);
  assert_eq!(v.length(), (2, 4));
}

Future

In the future, given some context and assurance, this crate might provide more complex traits, e.g., ContiguousIndexedSparseCollection.

Example

You can see more complete examples here.