Giter VIP home page Giter VIP logo

typenum's Introduction

crates.io Build Status

Typenum

Typenum is a Rust library for type-level numbers evaluated at compile time. It currently supports bits, unsigned integers, and signed integers.

Typenum depends only on libcore, and so is suitable for use on any platform!

For the full documentation, go here.

Importing

While typenum is divided into several modules, they are all re-exported through the crate root, so you can import anything contained herein with use typenum::whatever;, ignoring the crate structure.

You may also find it useful to treat the consts module as a prelude, perfoming a glob import.

Example

Here is a trivial example of typenum's use:

use typenum::{Sum, Exp, Integer, N2, P3, P4};

type X = Sum<P3, P4>;
assert_eq!(<X as Integer>::to_i32(), 7);

type Y = Exp<N2, P3>;
assert_eq!(<Y as Integer>::to_i32(), -8);

For a non-trivial example of its use, see one of the crates that depends on it. The full list is here. Of note are dimensioned which does compile-time type checking for arbitrary unit systems and generic-array which provides arrays whose length you can generically refer to.

Error messages

Typenum's error messages aren't great, and can be difficult to parse. The good news is that the fine folks at Auxon have written a tool to help with it. Please take a look at tnfilt.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

typenum's People

Contributors

akhilles avatar causal-agent avatar crlf0710 avatar dcrewi avatar ecstatic-morse avatar exphp avatar gereeter avatar glandium avatar jerry73204 avatar jswrenn avatar llogiq avatar m-ou-se avatar mwhudson avatar paholg avatar rphmeier avatar sebcrozet avatar wafflelapkin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.