https://github.com/calebwin/derive_lit
a tool to auto-generate literal macros for your data structure
https://github.com/calebwin/derive_lit
data-structures macro rust
Last synced: about 1 year ago
JSON representation
a tool to auto-generate literal macros for your data structure
- Host: GitHub
- URL: https://github.com/calebwin/derive_lit
- Owner: calebwin
- Created: 2019-10-28T20:42:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-28T20:55:54.000Z (over 6 years ago)
- Last Synced: 2025-02-28T07:15:46.939Z (about 1 year ago)
- Topics: data-structures, macro, rust
- Language: Rust
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `derive_lit`
[](https://crates.io/crates/derive_lit)
[](https://docs.rs/derive_lit)
Are you developing a data structure?
```rust
struct GroceryList {
num_items: usize,
item_ids: Vec
}
```
And your data structure lets you add data to it?
```rust
impl GroceryList {
fn new() -> Self {
Self {
num_items: 0,
item_ids: vec![]
}
}
fn push(&mut self, item_id: usize) {
self.item_ids.push(item_id);
}
}
```
Wouldn't it be cool if you could do this?
```rust
fn main() {
let groceries = grocery_list![
0,
9,
8,
4
];
// do something intersting with your GroceryList...
}
```
What if you could just...
```rust
use derive_lit::VecLit;
#[derive(VecLit)]
struct GroceryList {
num_items: usize,
item_ids: Vec
}
```
You can! Use `derive_lit::*`.
Just a `derive_lit = "0.1.0"` away!