#helper #macro

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

#404 in Rust patterns

Download history 2179/week @ 2022-06-03 2394/week @ 2022-06-10 1915/week @ 2022-06-17 1729/week @ 2022-06-24 1607/week @ 2022-07-01 1952/week @ 2022-07-08 2609/week @ 2022-07-15 2388/week @ 2022-07-22 2637/week @ 2022-07-29 2048/week @ 2022-08-05 1994/week @ 2022-08-12 1917/week @ 2022-08-19 2118/week @ 2022-08-26 2001/week @ 2022-09-02 2634/week @ 2022-09-09 1556/week @ 2022-09-16

8,738 downloads per month
Used in 18 crates (4 directly)

WTFPL license

36KB
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

  • debug-trace-macros