Expand description
By-reference compacting and separating of structures.
Similar to Compactable, but operates on borrowed containers. Elements are cloned
out of the borrowed structure, so the element types must implement Clone.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![Some(1), None, Some(3)];
let result = compact::<VecBrand, _, _, _>(&v);
assert_eq!(result, vec![1, 3]);Traits§
- RefCompactable
- A type class for data structures that can be compacted and separated by reference.
Functions§
- ref_
compact - Compacts a borrowed data structure of
Options, discardingNonevalues and cloningSomevalues. - ref_
separate - Separates a borrowed data structure of
Results into two data structures: one containing the clonedErrvalues and one containing the clonedOkvalues.