Struct CharStrategy
#[must_use = "strategies do nothing unless used"]
pub struct CharStrategy<'a> { /* private fields */ }
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
impl<'a> CharStrategy<'a>
fn new(special: Cow<'a, [char]>, preferred: Cow<'a, [RangeInclusive<char>]>, ranges: Cow<'a, [RangeInclusive<char>]>) -> SelfConstruct a new
CharStrategywith the parameters it will pass to the function underlyingselect_char().All arguments as per
select_char().fn new_borrowed(special: &'a [char], preferred: &'a [RangeInclusive<char>], ranges: &'a [RangeInclusive<char>]) -> SelfSame as
CharStrategy::new()but usingCow::Borrowedfor all parts.
Trait Implementations
impl<'a> Clone for CharStrategy<'a>
fn clone(&self) -> CharStrategy<'a>
impl<'a> Debug for CharStrategy<'a>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'a> Strategy for CharStrategy<'a>
type Tree = CharValueTree;type Value = char;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
Auto Trait Implementations
impl<'a> Freeze for CharStrategy<'a>
impl<'a> RefUnwindSafe for CharStrategy<'a>
impl<'a> Send for CharStrategy<'a>
impl<'a> Sync for CharStrategy<'a>
impl<'a> Unpin for CharStrategy<'a>
impl<'a> UnsafeUnpin for CharStrategy<'a>
impl<'a> UnwindSafe for CharStrategy<'a>
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for CharStrategy<'a>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for CharStrategy<'a>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for CharStrategy<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for CharStrategy<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for CharStrategy<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for CharStrategy<'a>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for CharStrategy<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for CharStrategy<'a>
where
T: ?Sized,
impl<T> ToOwned for CharStrategy<'a>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for CharStrategy<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for CharStrategy<'a>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for CharStrategy<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip<V> for CharStrategy<'a>
where
V: MultiLane<T>,
fn vzip(self) -> V