[−][src]Function permutator::unsafe_large_combination
pub unsafe fn unsafe_large_combination<'a, T: 'a>(
domain: &'a [T],
r: usize,
result: *mut [&'a T],
cb: impl FnMut()
)
Generate a r-combination from given domain and call callback function on each combination. The result will be return into ref mut pointer.
Parameter
domain : &[T]
- A slice contain a domain to generate r-combinationr : usize
- A size of combinationresult : *mut [&T]
- A mutable pointer to store resultcb : FnMut()
- A callback that notify caller on each combination
Panic
- It panic when
r > domain.len()
orr > result.len()
Rationale
This function took *mut [&T] to store result. It allow caller to easily share result outside callback function without copying/cloning each result. It sacrifice safety for performance.
Safety
- It doesn't check whether the pointer is valid or not.
- It doesn't free memory occupied by result.
- It may cause data race
- Mutating
result
may cause undesired behavior. - Storing
result
will get overwritten when new combination is return. - All other unsafe Rust condition may applied.