Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/llogiq/overflower
A Rust compiler plugin and support library to annotate overflow behavior
https://github.com/llogiq/overflower
arithmetic hacktoberfest
Last synced: 2 days ago
JSON representation
A Rust compiler plugin and support library to annotate overflow behavior
- Host: GitHub
- URL: https://github.com/llogiq/overflower
- Owner: llogiq
- License: apache-2.0
- Created: 2016-05-22T17:28:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-29T04:58:23.000Z (over 1 year ago)
- Last Synced: 2024-12-17T08:08:06.578Z (9 days ago)
- Topics: arithmetic, hacktoberfest
- Language: Rust
- Homepage:
- Size: 85 KB
- Stars: 105
- Watchers: 7
- Forks: 5
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# overflower
[![Build Status](https://travis-ci.org/llogiq/overflower.svg)](https://travis-ci.org/llogiq/overflower)
[![Current Version](https://img.shields.io/crates/v/overflower.svg)](https://crates.io/crates/overflower)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:
```toml
[dependencies]
overflower = "0.9"
```You may also make it an optional dependency (`overflower = { version = "0.4.6",
optional = true }`).Next, in your crate root, you need to add:
```rust
#![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:
```rust
#![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