pub struct Variant { /* private fields */ }
Expand description

An evaluated value represents the value of a an expression after evaluation.

Implementations

Converts the variant into a bool.

If the variant contains a string value, the “n” or “N” string convert into a false boolean, other strings convert into a true boolean.

If the variant contains a numeric value, either an integer or hexadecimal value, a 0 is converted into a false boolean, any other value into a true boolean.

If the variant contains a tristate value, only the false tristate value will be converted into a false boolean, either a true or maybe tristate value will be converted into a true value.

If the variant contains a boolean value, it will be returned as is.

Converts the variant into a tristate.

If the variant contains a string value, the “n” or “N” string convert into a false tristate, the “m” or “M” strings convert into a maybe tristate, any other strings convert into a true tristate.

If the variant contains a numeric value, either an integer or hexadecimal value, a 0 is converted into a false tristate, any other value into a true tristate.

If the variant contains a tristate value, it will be returned as is.

If the variant contains a boolean value, it will be converted as tristate.

Converts the variant into a hexadecimal value.

If the variant contains a string value, an attempt will be made to convert the string in to an integer. If that fails, and the string contains a “n” or “N” value, it is converted into 0x00, otherwise it is interpreted as 0x01.

If the variant contains a numeric value, either an integer or hexadecimal value, it will be returned as is, as hexadecimal representation. If the value is an integer, the sign will be converted.

If the variant contains a tristate value, if the tristate is a false value, it will be converted as 0x00, otherwise it will be converted as 0x01.

If the variant contains a boolean value, if the boolean is a false value, it will be converted as 0x00, otherwise it will be converted as 0x01.

Converts the variant into an integer value.

If the variant contains a string value, an attempt will be made to convert the string in to an integer. If that fails, and the string contains a “n” or “N” value, it is converted into 0, otherwise it is interpreted as 1.

If the variant contains a numeric value, either an integer or hexadecimal value, it will be returned as is, as hexadecimal representation. If the value is a hexadecimal, the sign will be converted.

If the variant contains a tristate value, if the tristate is a false value, it will be converted as 0, otherwise it will be converted as 1.

If the variant contains a boolean value, if the boolean is a false value, it will be converted as 0, otherwise it will be converted as 1.

Parses a given string, and attempts to return the closest matching variant belonging to the string. If the string contains a “y” or “Y” value, it is converted to a boolean true value, if the string contains a “n” or “N” value, it is converted to a boolean false value, if the string contains a “m” or “M” value, it is converted into a tristate maybe value.

If none of the above are true, an attempt is made to parse the string as hexadecimal and integer values. If unsuccessful, it is considered a normal string.

Converts a dot config value back into a Variant

Converts the representation of the variant from a normal value to a .config representation, as used by the Kconfig intermediate format.

Transforms the variant from the current variant type, into the given variant type

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Formats the display of the variant as value

Creates a variant from a string

Creates a variant form a hexadecimal value

Creates a variant from a string

Creates a variant from a tristate value

Converts to this type from the input type.

Creates a variant from a boolean value

Creates a variant from an integer value

Converts the variant into a hexadecimal value, using the Self::to_hex() function.

Converts the variant into a string, using the Self::to_string() function.

Converts the variant into a tristate value, using the Self::to_tristate() function.

Converts the variant into a boolean value, using the Self::to_bool() function.

Converts the variant into an integer value, using the Self::to_int() function.

Inverts the variant. If the variant is a boolean, inverts it directly. If the variant is not a boolean, it is converted to a tristate value, then it is inverted, such that the maybe tristate value, retains its properties.

The resulting type after applying the ! operator.

If self and other are both of integer or hexadecimal type, then comparison will be performed by integer comparison.

If self and other are both of boolean or tristate type, then comparison will be performed on tristate value, thus y > m > n.

If one is of type boolean/tristate and the other is of type integer/hexadecimal, the integer/hexadecimal type will be converted to it’s boolean equivalent, then compared

Everything else will be compared as if it were two string types.

Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.