[][src]Crate type_level_examples

This crate contains many examples of defining and using type-level values and functions.

You are free to copy any of the examples here,improvements to this examples should be (preferably) an issue or a pull request.

This is a library purely so that docs.rs can show documentation for it,do not use this crate as a dependency.

To run the examples do cargo run -- and then add one of the arguments from the help message.

Modules

_01_deserialize_uninitialized

This example demonstrates a type that is partially deserialized.

_02_mut_wrapper

This example demonstrates a wrapper type with a mutability parameter.

_03_vis_wrapper

This example demonstrates a struct that uses a const-struct to configure which fields are accessible.

_04_typesafe_builder

This example demonstrates a zero overhead builder using a ConstValue-parameter to track initialization of the fields.

_05_capabilities

This example demonstrates a zero overhead builder using a ConstValue-parameter to track initialization of the fields.

_06_channel

This example demonstrates a channel that can only send a limited ammount of values, checked at compile-time.

_07_split_mut

This example demonstrates an implementation of mutable reference splitting, where 2 mutable references are returned,with disjoint access to the fields .

_08_ranged_int

This example shows off a ranged unsigned integer type which is optimized for smaller storage.

_09_type_hof

This example shows off a type-level higher order function to define a constructor function where the type of the first parameter depends on the value of the second parameter (which is a ConstValue).

playground_01
playground_02
syntax_01_construct

This example shows off the different ways a type-level value can be constructed and converted to a runtime value.