pub enum Value {
Int(&'static [i64]),
Float(&'static [F64]),
Bool(&'static [bool]),
Str(&'static [&'static str]),
ListInt(&'static [&'static [i64]]),
ListStr(&'static [&'static [&'static str]]),
BitVector(usize, &'static [u64]),
Null,
}
Expand description
A collection of constant values representing various primitive and collection types.
This enumeration encapsulates integers, floats, booleans, and strings as well as lists of integers and strings, with each variant storing its data as a static slice to ensure efficient access. Additionally, a null variant is provided to denote the absence of a value.
Variants§
Int(&'static [i64])
Float(&'static [F64])
Bool(&'static [bool])
Str(&'static [&'static str])
ListInt(&'static [&'static [i64]])
ListStr(&'static [&'static [&'static str]])
BitVector(usize, &'static [u64])
Null
Implementations§
Source§impl Value
impl Value
Sourcepub fn with_examples(self, exs: &[usize]) -> Value
pub fn with_examples(self, exs: &[usize]) -> Value
Transforms the current value by selecting elements at indices specified in the examples slice and produces a new value of the same variant.
Iterates over the elements in the internal collection corresponding to the variant and constructs a new value by extracting items at the given indices. If the variant is Null, the result is also Null.
Source§impl Value
impl Value
Sourcepub fn ty(&self) -> Type
pub fn ty(&self) -> Type
Returns the type corresponding to the variant of the value. This function examines the value’s variant and returns the associated type, ensuring that each kind of value consistently maps to its specific type.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements contained within the value.
Examines the variant of the value and computes its length accordingly, using the inherent length of the underlying slice or collection, with a length of zero returned for the null variant.
Sourcepub fn length_inside(&self) -> Option<Vec<usize>>
pub fn length_inside(&self) -> Option<Vec<usize>>
Returns an optional vector of element lengths contained within the value. This method computes and returns a vector of lengths for each element when applicable, such as when the value holds strings or lists; for other cases, it yields None, indicating that individual element lengths are not defined.
Sourcepub fn flatten_leak(&self) -> &'static [&'static str]
pub fn flatten_leak(&self) -> &'static [&'static str]
Flattens the contained string(s) into a unified static slice of string references.
This function operates by taking a value holding either a singular string or a list of strings and returns a reference to a static slice where each element corresponds to a single-character substring from the original strings. It panics if the value is of any other type, ensuring that only supported string types are processed.
Sourcepub fn try_flatten_leak(&self) -> Option<&'static [&'static str]>
pub fn try_flatten_leak(&self) -> Option<&'static [&'static str]>
Converts a value holding strings into an optional flattened representation as a static slice of string slices.
Checks if the input value encapsulates either individual strings or a list of strings and produces a flattened collection where each element represents a single-character string slice or an element from the list, respectively. If the value does not match these string types, it returns None.
Sourcepub fn from_const(
ty: Type,
constants: impl ExactSizeIterator<Item = ConstValue>,
) -> Self
pub fn from_const( ty: Type, constants: impl ExactSizeIterator<Item = ConstValue>, ) -> Self
Creates a synthesized value from an iterator of constant values based on the specified type.
Converts each constant from the provided iterator to the corresponding native variant by mapping through type-specific conversion methods and collecting the results into the proper aggregated structure. If the type is unsupported for such conversion, the function triggers a panic with an appropriate error message.
Sourcepub fn substr(&self, other: &Value) -> bool
pub fn substr(&self, other: &Value) -> bool
Checks whether every string element in the first value is a substring of the corresponding string element in the second value.
Operates by iterating over paired elements from two string collections and returning true only if each element of the first collection is contained within the corresponding element of the second; if either value is not a string collection, it returns false.
Sourcepub fn some_substr(&self, other: &Value) -> bool
pub fn some_substr(&self, other: &Value) -> bool
Checks whether any string in the first value appears as a substring in the corresponding string of the second value. This function compares two values and, when both are collections of strings, pairs each corresponding element using a zipper technique and returns true if at least one pair satisfies the substring condition; in all other cases it returns false.
Sourcepub fn to_str(self) -> &'static [&'static str]
pub fn to_str(self) -> &'static [&'static str]
Converts an internal value into a statically allocated slice of string slices.
Transforms the underlying data by attempting to convert the current value into the desired string slice representation and immediately unwrapping the result. This operation guarantees that the conversion succeeds, provided the value is compatible with the expected type.
pub fn to_int(self) -> &'static [i64]
Sourcepub fn to_liststr(self) -> &'static [&'static [&'static str]]
pub fn to_liststr(self) -> &'static [&'static [&'static str]]
Converts a value into a static list of string slices by performing a conversion using the TryInto trait. Panics if the conversion fails, returning the resulting list of string slices upon success.
Sourcepub fn to_bool(self) -> &'static [bool]
pub fn to_bool(self) -> &'static [bool]
Converts the value into a static slice of booleans. This function attempts to transform the value into the corresponding boolean slice using an internal conversion mechanism and returns the result, panicking if the conversion fails.
Sourcepub fn to_bits(self) -> Bits
pub fn to_bits(self) -> Bits
Converts the boolean representation contained in the receiver into a bit vector.
Transforms the boolean values of the instance into a sequential bit representation suitable for bitwise manipulation. This function extracts a boolean slice from the instance and converts it into an aggregated Bits value.
Sourcepub fn is_all_true(&self) -> bool
pub fn is_all_true(&self) -> bool
Checks whether all boolean values in the object are true.
Determines if the object, when representing boolean values, contains only true elements by iterating over the booleans and verifying each one is true; if the object does not represent booleans, it returns false.
Sourcepub fn is_all_false(&self) -> bool
pub fn is_all_false(&self) -> bool
Determines whether all boolean values in the instance evaluate to false.
Evaluates the content of the instance by checking if it represents a boolean collection, returning true only when every boolean in that collection is false; otherwise, it returns false, defaulting to false if the instance does not correspond to a boolean value.
Sourcepub fn is_all_empty(&self) -> bool
pub fn is_all_empty(&self) -> bool
Checks whether every string element within the value is empty.
Determines if the current instance contains a collection of strings and, if so, verifies that all strings have zero length, returning false if the value is of a different type.
Sourcepub fn bool_not(self) -> Value
pub fn bool_not(self) -> Value
Negates each boolean element in the input value and returns a new value with the negated booleans.
This function converts the current instance into a boolean slice, applies logical negation to every element, and then collects the results back into a new instance that encapsulates the transformed boolean values.
Sourcepub fn eq_count(&self, other: &Self) -> usize
pub fn eq_count(&self, other: &Self) -> usize
Computes the number of pairwise equal elements shared between two values.
This function compares the corresponding elements of two instances by iterating over their internal collections and counting pairs that are equal. It supports several variants (such as integers, strings, floats, booleans, and lists) by aligning elements in parallel; when the compared types do not match, it returns zero.
Sourcepub fn eq_bits(&self, other: &Self) -> Option<Bits>
pub fn eq_bits(&self, other: &Self) -> Option<Bits>
Compares two values and computes a bit mask representing elementwise equality.
This function performs an elementwise comparison between the contents of two values of the same specific variant and returns an optional bit mask where each bit indicates whether corresponding elements are equal. If the two values do not belong to a matching variant that supports elementwise comparison (e.g., comparing an integer sequence to a boolean sequence), the function returns None.
Trait Implementations§
impl Copy for Value
impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> AllocForAny<T> for T
impl<T> AllocForAny<T> for T
Source§fn galloc(self) -> &'static T
fn galloc(self) -> &'static T
Provides a method to allocate an instance of T
on the heap with a static lifetime.
This implementation of galloc
takes ownership of the T
instance and uses the alloc
function to place it in a location with a static lifetime, presumably managing it in a way that ensures its persistence for the duration of the program.
This can be particularly useful for scenarios where a static lifetime is required, such as when interfacing with systems or patterns that necessitate global state or long-lived data.
Source§fn galloc_mut(self) -> &'static T
fn galloc_mut(self) -> &'static T
Provides a method that moves the instance and returns a reference to it allocated with a static lifetime.
This method utilizes alloc_mut
to perform the allocation, likely involving allocating the resource in a manner that ensures it lives for the entire duration of the application.
These semantics allow the user to safely assume that the reference will not expire during the program’s execution, making it suitable for long-lived data structures or operations that require such guarantees.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more