pub trait Fake: Sized {
// Provided methods
fn fake<U>(&self) -> U
where Self: FakeBase<U> { ... }
fn fake_with_rng<U, R: Rng + ?Sized>(&self, rng: &mut R) -> U
where Self: FakeBase<U> { ... }
}Expand description
Generate fake values given a type that implements Dummy.
The opposite of Dummy.
Generate default fake values with Faker.
Generate specific fake values with helpers in faker.
This trait is implemented for any type that implements Dummy:
Dummy should be implemented instead, and you get the Fake
implementation for free.
Dummy is similar to From trait, while Fake is similar to
Into trait. Except in this case Fake cannot be implemented.
§Examples
use fake::Fake;
assert_eq!(10.fake::<String>().len(), 10);
let a: [[u8; 2]; 3] = (1..10).fake();
let b: Option<Option<usize>> = (1..10).fake();Provided Methods§
fn fake<U>(&self) -> Uwhere
Self: FakeBase<U>,
fn fake_with_rng<U, R: Rng + ?Sized>(&self, rng: &mut R) -> Uwhere
Self: FakeBase<U>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.