ct-utils

Crates.ioct-utils
lib.rsct-utils
version0.0.1
sourcesrc
created_at2018-06-17 19:20:31.126406
updated_at2018-06-17 19:20:31.126406
descriptionCT-utils contains types and behaviours which resolve at compile time.
homepage
repositoryhttps://github.com/Bert-Proesmans/ct-utils
max_upload_size
id70517
size18,637
Proesmans Bert (Bert-Proesmans)

documentation

https://docs.rs/ct-utils

README

CT-Utils

This crate contains types and behaviours which resolve at compile time.

Getting started

Include this crate as dependancy by inserting the following into your Cargo.toml file.

[dependencies]
ct-utils = "1.10.0"

Inside your lib.rs or main.rs add the usage of this crate. Often used types are re-exported inside the prelude of this crate which lower the verbosity of your implementation. Otherwise all types are accessible through their fully qualified path.

#[macro_use] extern crate ct_utils;

// Optional
use ct_utils::prelude::*;

And you're all set!

Usage

An example of the included cons list is shown, which is the CTCons trait.

Construct a cons list of type items and calculate the offset of one specific type.

#[macro_use] extern crate ct_utils;

use ct_utils::prelude::*;
use ct_utils::ct_cons::Cons;

type BigList = Cons<Cons<Cons<Cons<Cons<CTConsTerm, i32>, u32>, f32>, i64>, usize>;

fn main() {
	let list_size = BigList::size();				// 1-indexed
	let list_offset = BigList::offset_of::<u64>(); 	// 0-indexed

	assert!(list_size > list_offset);
	assert_eq!(list_size, 5);
	assert_eq!(list_offset, 4);
}
Commit count: 5

cargo fmt