contains 0.1.0

A Container trait
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented3 out of 5 items with examples
  • Size
  • Source code size: 10.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.56 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Jon-Davis/contains
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Jon-Davis

Contains

The Contains crate has 2 traits Container and In.

Container

The Container trait can be used to abstract over types that can contain items: Vec<T>, &[T], HashMap<T>, Option<T>, ect.

use contains::Container;

let vec = vec![1, 2, 3, 4, 5];
let range = 0..5;
let option = Some(3);

let containers: &[&dyn Container<usize>] = &[&vec, &range, &option];
for container in containers {
  assert!(container.does_contain(&3));
}

In

The In trait is the Inverse of the Container trait and represents a type that is in a container. Mainly it reverse the call order by providing the is_in method.

use contains::{Container, In};

let range = 0..5;
assert!(range.does_contain(&3));    // using does_contain
assert!(3.is_in(&range));           // using in