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
use proptest::{bool, char};
use proptest::num::{isize, usize, f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
arbitrary!(
bool, f32, f64,
i8, i16, i32, i64, isize,
u8, u16, u32, u64, usize
);
use std::borrow::Cow;
type CharRange = (char, char);
type CowSlices<'a, T> = Cow<'a, [T]>;
const WHOLE_RANGE: &[CharRange] = &[('\x00', ::std::char::MAX)];
impl<'a> Default for CharParameters<'a> {
fn default() -> Self {
Self {
special: Cow::Borrowed(char::DEFAULT_SPECIAL_CHARS),
preferred: Cow::Borrowed(char::DEFAULT_PREFERRED_RANGES),
ranges: Cow::Borrowed(WHOLE_RANGE),
}
}
}
#[derive(Clone, PartialEq, Eq, Hash, Debug, From, Into)]
#[cfg_attr(feature = "frunk", derive(Generic))]
pub struct CharParameters<'a> {
special: CowSlices<'a, char>,
preferred: CowSlices<'a, CharRange>,
ranges: CowSlices<'a, CharRange>,
}
arbitrary!(char, char::CharStrategy<'a>, CharParameters<'a>; args => {
char::CharStrategy::new(args.special, args.preferred, args.ranges)
});