pub enum RantValue {
String(RantString),
Float(f64),
Int(i64),
Boolean(bool),
Function(RantFunctionRef),
List(RantListRef),
Map(RantMapRef),
Range(RantRange),
Special(RantSpecial),
Empty,
}
Expand description
A dynamically-typed Rant value.
Cloning
It is important to note that calling clone()
on a RantValue
will only result in a shallow clone of the data.
Since collection types like list
and map
are represented by handles to their actual contents, cloning these will
only make copies of these handles; both copies will still point to the same data.
Variants
String(RantString)
Tuple Fields
0: RantString
A Rant value of type string
. Passed by-value.
Float(f64)
Tuple Fields
0: f64
A Rant value of type float
. Passed by-value.
Int(i64)
Tuple Fields
0: i64
A Rant value of type int
. Passed by-value.
Boolean(bool)
Tuple Fields
0: bool
A Rant value of type bool
. Passed by-value.
Function(RantFunctionRef)
Tuple Fields
A Rant value of type function
. Passed by-reference.
List(RantListRef)
Tuple Fields
0: RantListRef
A Rant value of type list
. Passed by-reference.
Map(RantMapRef)
Tuple Fields
0: RantMapRef
A Rant value of type map
. Passed by-reference.
Range(RantRange)
Tuple Fields
0: RantRange
A Rant value of type range
. Passed by-value.
Special(RantSpecial)
Tuple Fields
0: RantSpecial
A Rant value of type special
. Passed by-value.
Empty
A Rant unit value of type empty
. Passed by-value.
Implementations
Returns true if the value is callable (e.g. a function).
Interprets this value as a boolean value according to Rant’s truthiness rules.
Types are converted as follows:
bool
returns itself.int
returnstrue
for any non-zero value; otherwise,false
.float
returnstrue
for any normal value; otherwise,false
.empty
returnsfalse
.- Collections (
string
,list
,map
,range
,block
) returntrue
if non-empty; otherwise,false
. - All other types return
true
.
Converts to a Rant bool
value.
Converts to a Rant int
value (or empty
if the conversion fails).
Converts to a Rant float
value (or empty
if the conversion fails).
Converts to a Rant string
value.
Converts to a Rant list
value.
Returns a shallow copy of the value.
Gets the Rant type associated with the value.
Indicates whether the value can be indexed into.
Attempts to get a value by index.
Attempts to set a value by index.
Attempts to get a value by key.
Attempts to set a value by key.
Raises self
to the exponent
power.
Calculates the absolute value.
Trait Implementations
Creates a value from an iterator. Read more
Convert from a RantValue
.
Returns true if the type can be used to represent an optional Rant parameter.
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
Auto Trait Implementations
impl !RefUnwindSafe for RantValue
impl !UnwindSafe for RantValue
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.