overflower

Crates.iooverflower
lib.rsoverflower
version0.4.6
sourcesrc
created_at2016-06-12 10:33:05.471459
updated_at2018-10-09 11:03:29.540608
descriptionA compiler plugin to easily select overflow behavior for all integer operations of an item
homepage
repositoryhttps://github.com/llogiq/overflower
max_upload_size
id5362
size26,702
(llogiq)

documentation

README

overflower

Build Status Current Version

This project contains a compiler plugin and supporting library to allow the programmer to annotate their code to declare how integer overflows should be dealt with.

Usage

Note: This needs a nightly compiler both for the compiler plugin and the supporting library, as the latter makes use of specialization, which is unstable for now.

To use it, you need the following in your Cargo.toml:

[dependencies]
overflower = "0.4.6"
overflower_support = "0.1.5"

You may also make it an optional dependency (overflower = { version = "0.4.6", optional = true }).

Next, in your crate root, you need to add:

#![feature(plugin)]
#![plugin(overflower)]

extern crate overflower_support;

// Now you can annotate items (up to and including the whole crate)
#[overflow(panic)]
fn panic_on_overflow() { .. }

#[overflow(wrap)]
fn like_you_just_dont_care() { .. }

#[overflow(saturate)]
fn too_much_sunlight() {
    #[overflow(default)]
    fn but_use_standard_ops_here() { .. }
    ..
}

In case of an optional dependency, you'd add the following instead:

#![cfg_attr(feature="overflower", feature(plugin))]
#![cfg_attr(feature="overflower", plugin(overflower))]

#[cfg(feature="overflower")
extern crate overflower_support;

// as well as the following instead of e.g. `#[overflow(wrap)]`
#[cfg_attr(feature="overflower", overflow(wrap))];

This is a bit of a work in progress, but most things should already be usable.

License: Apache 2.0

Commit count: 88

cargo fmt