Enum php_literal_parser::Value[][src]

pub enum Value {
    Bool(bool),
    Int(i64),
    Float(f64),
    String(String),
    Array(HashMap<Key, Value>),
    Null,
}
Expand description

A php value, can be either a bool, int, float, string, an array or null

note that in php all arrays are associative and thus represented by a map in rust.

You can convert a Value into a regular rust type by pattern matching or using the into_ functions.

Indexing

If the value is a php array, you can directly index into the Value, this will null if the Value is not an array or the key is not found

let value = Value::Array(hashmap!{
    "key".into() => "value".into(),
    10.into() => false.into()
});
assert_eq!(value["key"], "value");
assert_eq!(value[10], false);
assert!(value["not"]["found"].is_null());

Variants

Bool(bool)

Tuple Fields of Bool

0: bool
Int(i64)

Tuple Fields of Int

0: i64
Float(f64)

Tuple Fields of Float

0: f64
String(String)

Tuple Fields of String

0: String
Array(HashMap<Key, Value>)

Tuple Fields of Array

0: HashMap<Key, Value>
Null

Implementations

Check if the value is a bool

Check if the value is an integer

Check if the value is a float

Check if the value is a string

Check if the value is an array

Check if the value is null

Convert the value into a bool if it is one

Convert the value into a int if it is one

Convert the value into a float if it is one

Convert the value into a string if it is one

Convert the value into a hashmap if it is one

Get the value as &str if it is a string

Get the value as i64 if it is an int

Get the value as f64 if it is a float

Iterate over array key and value pairs if it is an array

Iterate over array keys if it is an array

Iterate over array values if it is an array

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

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.