#proc-macro

macro records

Proc macro for defining data storage structs

3 unstable releases

0.2.0 Jan 29, 2022
0.1.1 Dec 11, 2021
0.1.0 Dec 11, 2021

#372 in #proc-macro

Download history 28/week @ 2023-06-02 3/week @ 2023-06-09 77/week @ 2023-06-16 55/week @ 2023-06-23 58/week @ 2023-06-30 59/week @ 2023-07-07 35/week @ 2023-07-14 65/week @ 2023-07-21 34/week @ 2023-07-28 39/week @ 2023-08-04 44/week @ 2023-08-11 44/week @ 2023-08-18 26/week @ 2023-08-25 32/week @ 2023-09-01 47/week @ 2023-09-08 43/week @ 2023-09-15

157 downloads per month
Used in 10 crates (7 directly)

BSD-3-Clause

5KB
60 lines

Records

Records is a Rust library which adds an attribute designed for simple data classes ("records").

What is a record?

The record attribute takes a standard named struct and

  1. Makes all it's fields pub
  2. Gives it a constructor
  3. Implements convesrsion to/from tuples

Example

#[records::record]
pub struct Person {
  name: String,
}

pub fn main() {
  let person = Person::new(String::from("World"));
  println!("Hello, {}!", person.name);
}

lib.rs:

Procedral macro for data classes (records)

Dependencies

~1MB
~31K SLoC