3 unstable releases
0.2.0 | Jan 29, 2022 |
---|---|
0.1.1 | Dec 11, 2021 |
0.1.0 | Dec 11, 2021 |
#61 in #constructor
341 downloads per month
Used in 10 crates
(7 directly)
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
- Makes all it's fields
pub
- Gives it a constructor
- 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