Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lorem derive examples #175

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions fake/examples/derive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![allow(dead_code)]

use fake::decimal::*;
use fake::faker::boolean::en::*;
use fake::faker::company::en::*;
use fake::faker::lorem::en::*;
use fake::faker::name::en::*;
use fake::utils::{either, WrappedVal};
use fake::uuid::UUIDv4;
Expand Down Expand Up @@ -93,11 +96,20 @@ struct UnitStruct;
#[derive(Debug, Dummy)]
struct EmptyStruct {}

// #[derive(Debug, Dummy)]
// enum EmptyEnum {}
#[derive(Debug, Dummy)]
enum EmptyEnum {}

#[derive(Debug, Dummy)]
struct NewTypeTuple(#[dummy(faker = "1..100")] usize, String);

#[derive(Debug, Dummy)]
struct NewTypeWord(#[dummy(faker = "Word()")] String);

#[derive(Debug, Dummy)]
struct NewTypeWords(#[dummy(faker = "Words(4..10)")] Vec<String>);

#[derive(Debug, Dummy)]
struct NewType(#[dummy(faker = "1..100")] usize, String);
struct NewTypeSentence(#[dummy(faker = "Sentence(4..10)")] String);

#[derive(Debug, Dummy)]
#[allow(dead_code)]
Expand Down Expand Up @@ -125,10 +137,20 @@ fn main() {
let v: EmptyStruct = Faker.fake();
println!("{:#?}", v);

// This causes "any code following this expression is unreachable"
// let v: EmptyEnum = Faker.fake();
// println!("{:#?}", v);

let v: NewType = Faker.fake();
let v: NewTypeTuple = Faker.fake();
println!("{:#?}", v);

let v: NewTypeWord = Faker.fake();
println!("{:#?}", v);

let v: NewTypeWords = Faker.fake();
println!("{:#?}", v);

let v: NewTypeSentence = Faker.fake();
println!("{:#?}", v);

let v: uuid::Uuid = Faker.fake();
Expand Down
Loading