3 unstable releases

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

#61 in #constructor

Download history 94/week @ 2024-07-01 120/week @ 2024-07-08 165/week @ 2024-07-15 96/week @ 2024-07-22 24/week @ 2024-07-29 203/week @ 2024-08-05 26/week @ 2024-08-12 36/week @ 2024-08-19 112/week @ 2024-08-26 49/week @ 2024-09-02 10/week @ 2024-09-09 32/week @ 2024-09-16 137/week @ 2024-09-23 121/week @ 2024-09-30 40/week @ 2024-10-07 39/week @ 2024-10-14

341 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

~1.5MB
~36K SLoC