#struct #robot #human #catfishing

macro catfishing

Steal fields of another struct

1 unstable release

Uses new Rust 2024

0.0.1 May 6, 2025

#85 in #human

Download history 34/week @ 2025-04-30 80/week @ 2025-05-07

114 downloads per month

LGPL-3.0-or-later

12KB
94 lines

catfishing

#[catfishing(Robot)]
struct Human {
    age: usize,
    name: &'static str,
}

struct Robot(Human);

fn main() {
    let human = Human { age: 42, name: "John" };
    let robot = Robot(human);
    assert_eq!(robot.age(), 42);
    assert_eq!(robot.name(), "John");
}

Dependencies

~185–610KB
~14K SLoC