Skip to main content

Module ref_compactable

Module ref_compactable 

Source
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, discarding None values and cloning Some values.
ref_separate
Separates a borrowed data structure of Results into two data structures: one containing the cloned Err values and one containing the cloned Ok values.