#newtype #operator #macro #helper #foo #wartier #newtype-derive

newtype-ops

Mass-derive many operators for newtypes. Wartier than newtype_derive.

3 releases

0.1.4 May 16, 2019
0.1.3 Dec 15, 2016
0.1.2 Dec 15, 2016

#1988 in Rust patterns

Download history 1587/week @ 2024-09-14 1694/week @ 2024-09-21 1256/week @ 2024-09-28 1932/week @ 2024-10-05 1752/week @ 2024-10-12 1684/week @ 2024-10-19 1486/week @ 2024-10-26 6991/week @ 2024-11-02 4218/week @ 2024-11-09 7588/week @ 2024-11-16 8558/week @ 2024-11-23 5712/week @ 2024-11-30 4473/week @ 2024-12-07 4447/week @ 2024-12-14 1720/week @ 2024-12-21 1929/week @ 2024-12-28

13,187 downloads per month
Used in 22 crates (6 directly)

WTFPL license

37KB
436 lines

newtype-ops

License Documentation Crates.io Version Build Status

A operator-deriving macro for newtypes that is wartier than newtype_derive, and therefore better.[Citation needed]

pub struct Foo(i32);

newtype_ops! { [Foo] integer {:=} {^&}Self {^&}{Self i32} }

// alternatively
newtype_ops! { [Foo] {add sub mul div rem neg not bitand bitor bitxor} {:=} {^&}Self {^&}{Self i32} }

Installation

So for once I have finally decided to actually publish a crate this time.

Cargo.toml

[dependencies]
newtype-ops = "0.1"

Documentation

Funny thing, actually, pretty much the sole reason I published the crate was so that I could link to docs.rs.

See the documentation for newtype_ops!

License

WTFPL 2.0

No runtime deps

Features