Crate srestricted

Crate srestricted 

Source
Expand description

A create for creating and managing size restricted collections.

This crate can realise size restricted collections whichs len is clamped in between a MIN and MAX value. Those values are set with const generics. There are simple cases like NonEmpty to realise never empty collections in safe code. The main type of the crate is the SizeRestricted struct which handles the size restriction of the collection.

If you want to use your own collection type with SizeRestricted you just have to implement the LinearSizedCollection trait.

Modules§

test
Module for generating automated tests

Macros§

complete_test
Creates a complete test suite for the type created with $create by creating using all other test macros.
linear_collection_test
Test the coherence of a LinearSizedCollection.
size_restricted_collection
Tests for [SizeRestricted] collection with the underlying collection being the tested type.

Structs§

SizeRestricted
A wrapper around a LinearSizedCollection to restricts its size. The length is ensured to be between MIN and MAX including both MIN and MAX.

Enums§

SizeRangeError
An error representing a LinearSizedCollections len being out of the bound of a SizeRestricted

Traits§

LinearSizedCollection
A trait for linear collections which have a determinable size at any given point in time.
ViewMut
Used to receive a mutable view into a linear collection

Type Aliases§

ExactSized
A collection which has an exact amount of elements which can’t change
NonEmpty
A never empty linear sized collection