Skip to content

Commit

Permalink
Add lorem derive examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Apr 5, 2024
1 parent 3e03e54 commit 7ea367b
Showing 1 changed file with 26 additions and 4 deletions.
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

0 comments on commit 7ea367b

Please sign in to comment.