[][src]Function natural_slice::property::encode_property

pub fn encode_property<T: Ord, Encoded: TryFrom<usize>>(
    data: &[T],
    property_mapping: &dyn Fn(&T) -> u8,
    base: u8
) -> Result<Encoded, Encoded::Error>

Encode a property of a slice of data with finite cardinality into a single number There must be a mapping from this property to a digit in a certain base The output is bound by base^(data.len() - 1) Precondition: the property being encoded must satisfy the parity property, which is to say that summing all the values of the property should give a multiple of the base. This is used to omit one "bit" in that base as it can be reconstituted later using parity.