pub enum Op1Enum {
Show 43 variants
Len(Len),
ToInt(ToInt),
ToStr(ToStr),
Neg(Neg),
IsPos(IsPos),
IsZero(IsZero),
IsNatural(IsNatural),
RetainLl(RetainLl),
RetainLc(RetainLc),
RetainN(RetainN),
RetainL(RetainL),
RetainLN(RetainLN),
Map(Map),
Filter(Filter),
Uppercase(Uppercase),
Lowercase(Lowercase),
AsMonth(AsMonth),
AsDay(AsDay),
AsYear(AsYear),
AsWeekDay(AsWeekDay),
ParseTime(ParseTime),
ParseDate(ParseDate),
ParseInt(ParseInt),
ParseMonth(ParseMonth),
ParseWeekday(ParseWeekday),
ParseFloat(ParseFloat),
FormatInt(FormatInt),
FormatFloat(FormatFloat),
FormatTime(FormatTime),
FormatMonth(FormatMonth),
FormatWeekday(FormatWeekday),
FNeg(FNeg),
FAbs(FAbs),
FIsPos(FIsPos),
FExp10(FExp10),
IntToFloat(IntToFloat),
FloatToInt(FloatToInt),
StrToFloat(StrToFloat),
FIsZero(FIsZero),
FNotNeg(FNotNeg),
FLen(FLen),
BvNot(BvNot),
BvNeg(BvNeg),
}
Expand description
An enum that defines unary operations for expressions within the string synthesis framework.
This enumeration, Op1Enum
, includes a wide array of operations that can be applied to a single operand.
The operations cover a diverse set of functionalities such as conversions between data types (e.g., ToInt
, ToStr
, IntToFloat
, FloatToInt
, StrToFloat
), string manipulations like changing case (Uppercase
, Lowercase
) and retaining specific character types (RetainLl
, RetainLc
, RetainN
, RetainL
, RetainLN
).
Additionally, the enum supports various mathematical and logical checks (IsPos
, IsZero
, IsNatural
, FIsPos
, FIsZero
, FNotNeg
), numerical operations (Neg
, FNeg
, FAbs
, FExp10
), formatting (FormatInt
, FormatFloat
, FormatTime
, FormatMonth
, FormatWeekday
), and parsing (ParseTime
, ParseDate
, ParseInt
, ParseMonth
, ParseWeekday
, ParseFloat
).
It also includes utilities like Len
for measuring length and several date-related transformations (AsMonth
, AsDay
, AsYear
, AsWeekDay
).
This diverse suite of operations enables flexible and efficient manipulation of data types required for string synthesis challenges.
Variants§
Len(Len)
ToInt(ToInt)
ToStr(ToStr)
Neg(Neg)
IsPos(IsPos)
IsZero(IsZero)
IsNatural(IsNatural)
RetainLl(RetainLl)
RetainLc(RetainLc)
RetainN(RetainN)
RetainL(RetainL)
RetainLN(RetainLN)
Map(Map)
Filter(Filter)
Uppercase(Uppercase)
Lowercase(Lowercase)
AsMonth(AsMonth)
AsDay(AsDay)
AsYear(AsYear)
AsWeekDay(AsWeekDay)
ParseTime(ParseTime)
ParseDate(ParseDate)
ParseInt(ParseInt)
ParseMonth(ParseMonth)
ParseWeekday(ParseWeekday)
ParseFloat(ParseFloat)
FormatInt(FormatInt)
FormatFloat(FormatFloat)
FormatTime(FormatTime)
FormatMonth(FormatMonth)
FormatWeekday(FormatWeekday)
FNeg(FNeg)
FAbs(FAbs)
FIsPos(FIsPos)
FExp10(FExp10)
IntToFloat(IntToFloat)
FloatToInt(FloatToInt)
StrToFloat(StrToFloat)
FIsZero(FIsZero)
FNotNeg(FNotNeg)
FLen(FLen)
BvNot(BvNot)
BvNeg(BvNeg)
Implementations§
Source§impl Op1Enum
impl Op1Enum
Sourcepub fn eval(&self, a1: Value) -> Value
pub fn eval(&self, a1: Value) -> Value
Evaluates a unary operation on a given value and returns the result.
This function takes a reference to self as an Op1Enum
instance and a Value
representing the operand for the unary operation.
It attempts to evaluate the operation by calling the try_eval
method with the provided argument and returns the second element of the resulting tuple, which is the computed Value
.
This method assumes that the operation is successfully executed, as it directly takes the result part of the tuple from try_eval
.
Source§impl Op1Enum
impl Op1Enum
Sourcepub fn from_name(name: &str, config: &Config) -> Self
pub fn from_name(name: &str, config: &Config) -> Self
Implements a method to create an instance of the enumeration from a string identifier.
This method takes a string name
representing the desired operation and a config
reference, which helps configure certain operational aspects, to return the corresponding Op1Enum
variant.
Internally, it uses a macro, _do
, to iterate over potential operations and check if their names match the given string identifier.
If a match is found, it returns the operation configured with the supplied configuration.
For specific operations like “str.len”, “str.from_int”, and “str.to_int”, direct matches that do not utilize the macro are provided for convenience.
If no operation matches the given string name, the method panics with an “Unknown Operator” error message.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Provides a method to retrieve the name of a unary operation as a static string.
The method uses a macro to match the current instance of the enumeration against all possible variants of unary operations defined by Op1Enum
.
If the current instance matches one of these variants, it returns the corresponding name by invoking the name()
method of the matched operation.
It leverages a macro named for_all_op1!
to iterate through all operation variants, ensuring extensibility and maintainability when new operations are introduced.
If no match is found, the method panics, indicating an unexpected state or missing variant handling.
Trait Implementations§
Source§impl Display for Op1Enum
impl Display for Op1Enum
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the operation represented by Op1Enum
for printing.
This implementation attempts to match the enum variant of the Op1Enum
and writes its argument to the provided formatter.
The macro crate::for_all_op1!()
is used to iterate over all possible unary operation variants, facilitating the matching process.
If an appropriate match is found, it writes the associated argument to the formatter.
If no match is found using the macro, it completes without any action.
This approach enables a concise and consistent output for each variant when formatted.
Source§impl Enumerator1 for Op1Enum
impl Enumerator1 for Op1Enum
Source§impl From<FloatToInt> for Op1Enum
impl From<FloatToInt> for Op1Enum
Source§fn from(v: FloatToInt) -> Op1Enum
fn from(v: FloatToInt) -> Op1Enum
Source§impl From<FormatFloat> for Op1Enum
impl From<FormatFloat> for Op1Enum
Source§fn from(v: FormatFloat) -> Op1Enum
fn from(v: FormatFloat) -> Op1Enum
Source§impl From<FormatMonth> for Op1Enum
impl From<FormatMonth> for Op1Enum
Source§fn from(v: FormatMonth) -> Op1Enum
fn from(v: FormatMonth) -> Op1Enum
Source§impl From<FormatTime> for Op1Enum
impl From<FormatTime> for Op1Enum
Source§fn from(v: FormatTime) -> Op1Enum
fn from(v: FormatTime) -> Op1Enum
Source§impl From<FormatWeekday> for Op1Enum
impl From<FormatWeekday> for Op1Enum
Source§fn from(v: FormatWeekday) -> Op1Enum
fn from(v: FormatWeekday) -> Op1Enum
Source§impl From<IntToFloat> for Op1Enum
impl From<IntToFloat> for Op1Enum
Source§fn from(v: IntToFloat) -> Op1Enum
fn from(v: IntToFloat) -> Op1Enum
Source§impl From<ParseFloat> for Op1Enum
impl From<ParseFloat> for Op1Enum
Source§fn from(v: ParseFloat) -> Op1Enum
fn from(v: ParseFloat) -> Op1Enum
Source§impl From<ParseMonth> for Op1Enum
impl From<ParseMonth> for Op1Enum
Source§fn from(v: ParseMonth) -> Op1Enum
fn from(v: ParseMonth) -> Op1Enum
Source§impl From<ParseWeekday> for Op1Enum
impl From<ParseWeekday> for Op1Enum
Source§fn from(v: ParseWeekday) -> Op1Enum
fn from(v: ParseWeekday) -> Op1Enum
Source§impl From<StrToFloat> for Op1Enum
impl From<StrToFloat> for Op1Enum
Source§fn from(v: StrToFloat) -> Op1Enum
fn from(v: StrToFloat) -> Op1Enum
Source§impl ParsingOp for Op1Enum
impl ParsingOp for Op1Enum
fn parse_into(&self, input: &'static str) -> Vec<(&'static str, ConstValue)>
fn parse_all(&self, ctx: &Context) -> Vec<(&'static str, ConstValue)>
Source§impl TryInto<FloatToInt> for Op1Enum
impl TryInto<FloatToInt> for Op1Enum
Source§impl TryInto<FormatFloat> for Op1Enum
impl TryInto<FormatFloat> for Op1Enum
Source§impl TryInto<FormatMonth> for Op1Enum
impl TryInto<FormatMonth> for Op1Enum
Source§impl TryInto<FormatTime> for Op1Enum
impl TryInto<FormatTime> for Op1Enum
Source§impl TryInto<FormatWeekday> for Op1Enum
impl TryInto<FormatWeekday> for Op1Enum
Source§impl TryInto<IntToFloat> for Op1Enum
impl TryInto<IntToFloat> for Op1Enum
Source§impl TryInto<ParseFloat> for Op1Enum
impl TryInto<ParseFloat> for Op1Enum
Source§impl TryInto<ParseMonth> for Op1Enum
impl TryInto<ParseMonth> for Op1Enum
Source§impl TryInto<ParseWeekday> for Op1Enum
impl TryInto<ParseWeekday> for Op1Enum
Source§impl TryInto<StrToFloat> for Op1Enum
impl TryInto<StrToFloat> for Op1Enum
impl Eq for Op1Enum
impl StructuralPartialEq for Op1Enum
Auto Trait Implementations§
impl Freeze for Op1Enum
impl RefUnwindSafe for Op1Enum
impl Send for Op1Enum
impl Sync for Op1Enum
impl Unpin for Op1Enum
impl UnwindSafe for Op1Enum
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