Skip to content

Type-enforced sorted guarantees for ordinary collections.

License

Notifications You must be signed in to change notification settings

Zoomulator/rust-sorted

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorted

A Rust library that provides compile time contracts for sorted sequences.

Distributed under the MIT license.

Documentation

Status

Latest version on crates.io Build Status

This library is currently being drafted and is not fit for any use at this time.

Reasoning

By limiting sorted types to operations that keeps the sorting order it's possible to give guarantees at compile time. Even different kinds of sort ordering can be typed and forbids collections sorted by different keys or comparisons to be mixed.

Why

If you're dealing with a lot of sorted and unsorted arrays, vectors or iterators in a lot of places in your code it can be easy to slip up and add an element in the wrong place or use an unsorted list where a sorted one is required. Compile time guarantees helps you avoid bugs and declare intentions in those cases.

That said, this library won't provide any actual functionality to your code, except a few convenience methods that keeps the sorted contract. If you're not holding array types sorted for any length of time or bigger amounts, this library is probably overkill.

How

This library implements a number of constraint type wrappers that restricts the mutable operations of Vec and slices to operations that retains the sorted order. Non-mut operations are still provided via Deref. These sorted types can only be created by sorting a regular sequence or copying another sorted type.

Examples

Look at tests/usage.rs on how to use the sorted types.

About

Type-enforced sorted guarantees for ordinary collections.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages