3 unstable releases

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

#59 in #constructor

Download history 105/week @ 2024-07-20 52/week @ 2024-07-27 157/week @ 2024-08-03 64/week @ 2024-08-10 45/week @ 2024-08-17 100/week @ 2024-08-24 47/week @ 2024-08-31 25/week @ 2024-09-07 26/week @ 2024-09-14 90/week @ 2024-09-21 165/week @ 2024-09-28 38/week @ 2024-10-05 42/week @ 2024-10-12 53/week @ 2024-10-19 6/week @ 2024-10-26 14/week @ 2024-11-02

118 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
~37K SLoC