#macro-derive #traits #tuple-struct #debugging #partial-eq #ops-derive

macro ops-derive2

Derive macros for implementing the std::ops traits

2 unstable releases

Uses new Rust 2024

0.2.0 Aug 8, 2025
0.1.0 Aug 8, 2025

#1223 in Procedural macros

MIT/Apache

9KB
187 lines

ops-derive2

This is a fork of the ops-derive crate.

Extra features:

  • Tuple struct support
  • std::ops::* is implemented for Into<T> instead of T

Examples

use ops_derive2::*;

#[derive(Debug, PartialEq, AutoAdd)]
pub struct Point(u32, u32, u32);

impl Point {
	pub fn new(x: u32, y: u32, z: u32) -> Self {
		Self(x, y, z)
	}
}

fn main() {
	let a = Point::new(1, 2, 3);
	let b = Point::new(4, 5, 6);
	let c = Point::new(5, 7, 9);

	assert_eq!(a + b, c);
}

Dependencies

~140–540KB
~13K SLoC