#collection #traits #length #cl #describe

no-std cl-traits

Provides traits that describe collections

26 releases (15 stable)

7.0.0 May 19, 2022
6.0.0 Jul 18, 2021
5.0.1 May 3, 2021
5.0.0 Jan 29, 2021
0.1.0 Mar 12, 2019

#814 in Development tools

Download history 5/week @ 2024-02-14 42/week @ 2024-02-21 9/week @ 2024-02-28

56 downloads per month
Used in 5 crates (4 directly)

Apache-2.0

99KB
2.5K SLoC

Collection Traits (cl-traits)

CI crates.io Documentation License Rustc

Yet another library that generalizes collections.

This crate provides a single method for each trait to achieve maximum flexibility and freedom instead of imposing an abstraction subset for all situations and users.

Examples

use cl_traits::*;

struct SomeCustomVector(Vec<i32>, Vec<i32>);

impl Length for SomeCustomVector {
  #[inline]
  fn length(&self) -> usize {
    self.0.length() + self.1.length()
  }
}

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

Dependencies

~0–355KB