Enum Value

Source
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

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn to_int(self) -> &'static [i64]

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, _derive_more_display_formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&'static [&'static [&'static str]]> for Value

Source§

fn from(original: &'static [&'static [&'static str]]) -> Value

Converts to this type from the input type.
Source§

impl From<&'static [&'static [i64]]> for Value

Source§

fn from(original: &'static [&'static [i64]]) -> Value

Converts to this type from the input type.
Source§

impl From<&'static [&'static str]> for Value

Source§

fn from(original: &'static [&'static str]) -> Value

Converts to this type from the input type.
Source§

impl From<&'static [F64]> for Value

Source§

fn from(original: &'static [F64]) -> Value

Converts to this type from the input type.
Source§

impl From<&'static [bool]> for Value

Source§

fn from(original: &'static [bool]) -> Value

Converts to this type from the input type.
Source§

impl From<&'static [i64]> for Value

Source§

fn from(original: &'static [i64]) -> Value

Converts to this type from the input type.
Source§

impl From<()> for Value

Source§

fn from(original: ()) -> Value

Converts to this type from the input type.
Source§

impl From<(usize, &'static [u64])> for Value

Source§

fn from(original: (usize, &'static [u64])) -> Value

Converts to this type from the input type.
Source§

impl Hash for Value

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Value> for &'static [&'static [&'static str]]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for &'static [&'static [i64]]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for &'static [&'static str]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for &'static [F64]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for &'static [bool]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for &'static [i64]

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for ()

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for (usize, &'static [u64])

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Value

Source§

impl Eq for Value

Source§

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

Source§

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

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V