#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

#2166 in Rust patterns

Download history 675/week @ 2024-01-05 1216/week @ 2024-01-12 1034/week @ 2024-01-19 877/week @ 2024-01-26 1050/week @ 2024-02-02 973/week @ 2024-02-09 828/week @ 2024-02-16 884/week @ 2024-02-23 1190/week @ 2024-03-01 1379/week @ 2024-03-08 1038/week @ 2024-03-15 1064/week @ 2024-03-22 1003/week @ 2024-03-29 723/week @ 2024-04-05 1118/week @ 2024-04-12 925/week @ 2024-04-19

3,899 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