#data #random #faker #macro-derive #fake-data

macro dummy_tmp_fork

Macros implementation of #[derive(Dummy)]

1 unstable release

new 0.9.1 Nov 6, 2024

#7 in #faker

MIT/Apache

15KB
269 lines

Dummy

Latest Version

This crate provide derive(Dummy) macros. use it via fake crate with derive feature

Installation

[dependencies]
fake = { version = "3.0", features=["derive"] }

Usage

use fake::faker::boolean::en::*;
use fake::faker::company::en::*;
use fake::faker::name::en::*;
use fake::Dummy;
use fake::{Fake, Faker};

#[derive(Debug, Dummy)]
pub struct Order {
    #[dummy(faker = "1000..")]
    order_id: usize,

    #[dummy(faker = "Name()")]
    customer: String,

    #[dummy(faker = "(Faker, 3..5)")]
    items: Vec<Item>,

    #[dummy(faker = "Boolean(70)")]
    paid: bool,
}

#[derive(Debug, Dummy)]
pub struct Item {
    #[dummy(faker = "1..100")]
    product_id: usize,

    qty: u8,

    #[dummy(faker = "CompanyName()")]
    company: String,
}

fn main() {
    let order: Order = Faker.fake();
    println!("{:#?}", order);
}

License

This project is licensed under either of

at your option.

Dependencies

~0.5–1MB
~22K SLoC