use-set
Install
[]
= "0.0.1"
Foundation
use-set provides a deliberately small set-theoretic surface over ordinary slices. It treats duplicates as membership noise, exposes direct predicates such as contains_member, is_subset, and are_disjoint, and returns unique Vec<T> values for set operations while preserving first-seen order. The API stays explicit and dependency-free instead of introducing a wrapper collection type.
| Helper group | Primary items | Best fit |
|---|---|---|
| Membership and relations | contains_member, is_subset, are_disjoint |
Call sites that want readable set checks over existing slices |
| Set operations | set_union, set_intersection, set_difference |
Small apps and utilities that need explicit, unique results without introducing a custom set type |
| Exclusive-membership helpers | set_symmetric_difference |
Comparing two slices for values that appear on exactly one side |
When to use directly
Choose use-set directly when mathematical set helpers are the only surface you need and you want to keep that concern narrower than the umbrella facade.
| Scenario | Use use-set directly? |
Why |
|---|---|---|
| You already have slices and want explicit set predicates | Yes | The API avoids extra collection wrappers and keeps intent obvious |
| You need unique set-operation results but still care about input order | Yes | The operation helpers preserve first-seen order while removing duplicates |
| You also need geometry, probability, or other math domains | Usually no | use-math can compose the concrete surfaces behind features |
Scope
- The current surface is intentionally small and concrete.
- Helpers work over ordinary slices and cloned output vectors instead of a custom set type.
- Boolean logic and general-purpose collection utilities belong in adjacent or external crates.
Examples
Membership and relations
use ;
let left = ;
let right = ;
assert!;
assert!;
assert!;
Order-preserving set operations
use ;
let left = ;
let right = ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Status
use-set is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent collection and algebra crates continue to grow around it.