1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::faker::job::raw::*;
use crate::locales::Data;
use crate::{Dummy, Fake};
use rand::seq::SliceRandom;
use rand::Rng;
impl<L: Data> Dummy<Seniority<L>> for String {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Seniority<L>, rng: &mut R) -> Self {
let s = *L::JOB_SENIORITY.choose(rng).unwrap();
s.into()
}
}
impl<L: Data> Dummy<Seniority<L>> for &str {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Seniority<L>, rng: &mut R) -> Self {
*L::JOB_SENIORITY.choose(rng).unwrap()
}
}
impl<L: Data> Dummy<Field<L>> for String {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Field<L>, rng: &mut R) -> Self {
let s = *L::JOB_FIELD.choose(rng).unwrap();
s.into()
}
}
impl<L: Data> Dummy<Field<L>> for &str {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Field<L>, rng: &mut R) -> Self {
*L::JOB_FIELD.choose(rng).unwrap()
}
}
impl<L: Data> Dummy<Position<L>> for String {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Position<L>, rng: &mut R) -> Self {
let s = *L::JOB_POSITION.choose(rng).unwrap();
s.into()
}
}
impl<L: Data> Dummy<Position<L>> for &str {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Position<L>, rng: &mut R) -> Self {
*L::JOB_POSITION.choose(rng).unwrap()
}
}
impl<L: Data + Copy> Dummy<Title<L>> for String {
fn dummy_with_rng<R: Rng + ?Sized>(c: &Title<L>, rng: &mut R) -> Self {
L::JOB_TITLE_TPL
.replace("{Seniority}", Seniority(c.0).fake_with_rng::<&str, _>(rng))
.replace("{Field}", Field(c.0).fake_with_rng::<&str, _>(rng))
.replace("{Position}", Position(c.0).fake_with_rng::<&str, _>(rng))
}
}