pub fn large_combination_cell<'a, T: 'a>(
    domain: &'a [T],
    r: usize,
    result: Rc<RefCell<&'a mut [&'a T]>>,
    cb: impl FnMut()
)
Expand description

Generate a r-combination from given domain and call callback function on each combination. The result will be return into Rc<RefCell<>>.

Parameter

  1. domain : &[T] - A slice contain a domain to generate r-combination
  2. r : usize - A size of combination
  3. ’result : Rc<RefCell<&mut [&T]>>` - A result container object.
  4. cb : FnMut() - A callback that notify caller on each combination

Panic

It panic when r > domain.len() or r > result.borrow().len()

Rationale

It allow easily safe sharing of result to some degree with minor performance overhead and some some usage constraint.

  • result will get overwritten on each new combination.
  • Storing result will get overwritten when new combination is return.