Struct Subsets

Source
pub struct Subsets<T: Clone> { /* private fields */ }
Expand description

Subsets of a base collection.

The pattern for the yielded values is:

  1. vec![]
  2. vec![a]
  3. vec![b]
  4. vec![a,b]
  5. vec![c]
  6. vec![a,c]
  7. vec![b,c]
  8. vec![a,b,c]

where the a is the first element of the base collection, b is the second, and so on.

Example:

use boulder::{Generator, Subsets};

let mut g = Subsets::new(1..4);
assert_eq!(g.generate(), vec![]);
assert_eq!(g.generate(), vec![1]);
assert_eq!(g.generate(), vec![2]);
assert_eq!(g.generate(), vec![1,2]);

Implementations§

Source§

impl<T: Clone> Subsets<T>

Source

pub fn new<X: IntoIterator<Item = T>>(base: X) -> Self

Create a new generator.

base will be collected into a Vec for re-sampling.

Trait Implementations§

Source§

impl<T: Clone + Clone> Clone for Subsets<T>

Source§

fn clone(&self) -> Subsets<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Clone + 'static> Generator for Subsets<T>

Source§

type Output = Vec<T>

The output type.
Source§

fn generate(&mut self) -> Self::Output

Make a new object. Read more
Source§

impl<C, T> GeneratorWithPersianRug<C> for Subsets<T>
where T: Clone + 'static, C: Context,

Source§

type Output = Vec<T>

Available on crate feature persian-rug only.
The output type.
Source§

fn generate<'b, B>(&mut self, context: B) -> (Self::Output, B)
where B: 'b + Mutator<Context = C>,

Available on crate feature persian-rug only.
Make a new object. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Subsets<T>

§

impl<T> RefUnwindSafe for Subsets<T>
where T: RefUnwindSafe,

§

impl<T> Send for Subsets<T>
where T: Send,

§

impl<T> Sync for Subsets<T>
where T: Sync,

§

impl<T> Unpin for Subsets<T>
where T: Unpin,

§

impl<T> UnwindSafe for Subsets<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.