pub struct CharStrategy<'a> { /* private fields */ }
Expand description

Strategy for generating chars.

Character selection is more sophisticated than integer selection. Naïve selection (particularly in the larger context of generating strings) would result in starting inputs like ꂡ螧轎ቶᢹ糦狥芹ᘆ㶏曊ᒀ踔虙ჲ and “simplified” inputs consisting mostly of control characters. It also has difficulty locating edge cases, since the vast majority of code points (such as the enormous CJK regions) don’t cause problems for anything with even basic Unicode support.

Instead, character selection is always based on explicit ranges, and is designed to bias to specifically chosen characters and character ranges to produce inputs that are both more useful and easier for humans to understand. There are also hard-wired simplification targets based on ASCII instead of simply simplifying towards NUL to avoid problematic inputs being reduced to a bunch of NUL characters.

Shrinking never crosses ranges. If you have a complex range like [A-Za-z] and the starting point x is chosen, it will not shrink to the first A-Z group, but rather simply to a.

The usual way to get instances of this class is with the module-level ANY constant or range function. Directly constructing a CharStrategy is only necessary for complex ranges or to override the default biases.

Implementations

Construct a new CharStrategy with the parameters it will pass to the function underlying select_char().

All arguments as per select_char().

Same as CharStrategy::new() but using Cow::Borrowed for all parts.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The value tree generated by this Strategy.

The type of value used by functions under test generated by this Strategy. Read more

Generate a new value tree from the given runner. Read more

Returns a strategy which produces values transformed by the function fun. Read more

Returns a strategy which produces values of type O by transforming Self with Into<O>. Read more

Returns a strategy which produces values transformed by the function fun, which is additionally given a random number generator. Read more

Maps values produced by this strategy into new strategies and picks values from those strategies. Read more

Maps values produced by this strategy into new strategies and picks values from those strategies while considering the new strategies to be independent. Read more

Similar to prop_ind_flat_map(), but produces 2-tuples with the input generated from self in slot 0 and the derived strategy in slot 1. Read more

Returns a strategy which only produces values accepted by fun. Read more

Returns a strategy which only produces transformed values where fun returns Some(value) and rejects those where fun returns None. Read more

Returns a strategy which picks uniformly from self and other. Read more

Generate a recursive structure with self items as leaves. Read more

Shuffle the contents of the values produced by this strategy. Read more

Erases the type of this Strategy so it can be passed around as a simple trait object. Read more

Erases the type of this Strategy so it can be passed around as a simple trait object. Read more

Wraps this strategy to prevent values from being subject to shrinking. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.