pub struct RandomPool<T>(/* private fields */);Implementationsยง
Sourceยงimpl<T> RandomPool<T>
impl<T> RandomPool<T>
Sourcepub fn new(vec: Vec<T>) -> Self
pub fn new(vec: Vec<T>) -> Self
Examples found in repository?
examples/pool.rs (lines 4-6)
3fn main() {
4 let some_pool = RandomPool::new(vec![
5 "TEST", "test", "TeSt", "tEsT",
6 ]);
7
8 println!("Something any: {}", some_pool.get());
9
10 let address_pool = RandomPool::new(vec![
11 Address(&Locale::EN), Address(&Locale::RU),
12 ]);
13
14 println!("Random address: {}", address_pool.get().city());
15
16 let complex_pool = RandomPool::new(vec![
17 ComplexProvider::new(&Locale::EN), ComplexProvider::new(&Locale::RU),
18 ]);
19
20 println!("Random complex provider: {}", complex_pool.get().person.name(Some(Gender::MALE)))
21}Sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Examples found in repository?
examples/pool.rs (line 8)
3fn main() {
4 let some_pool = RandomPool::new(vec![
5 "TEST", "test", "TeSt", "tEsT",
6 ]);
7
8 println!("Something any: {}", some_pool.get());
9
10 let address_pool = RandomPool::new(vec![
11 Address(&Locale::EN), Address(&Locale::RU),
12 ]);
13
14 println!("Random address: {}", address_pool.get().city());
15
16 let complex_pool = RandomPool::new(vec![
17 ComplexProvider::new(&Locale::EN), ComplexProvider::new(&Locale::RU),
18 ]);
19
20 println!("Random complex provider: {}", complex_pool.get().person.name(Some(Gender::MALE)))
21}pub fn get_mut(&mut self) -> &mut T
Auto Trait Implementationsยง
impl<T> Freeze for RandomPool<T>
impl<T> RefUnwindSafe for RandomPool<T>where
T: RefUnwindSafe,
impl<T> Send for RandomPool<T>where
T: Send,
impl<T> Sync for RandomPool<T>where
T: Sync,
impl<T> Unpin for RandomPool<T>where
T: Unpin,
impl<T> UnwindSafe for RandomPool<T>where
T: UnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more