[−][src]Enum php_literal_parser::Value
Variants
Bool(bool)
Int(i64)
Float(f64)
String(String)
Implementations
impl Value
[src]
A php value, can be either a bool, int, float, string or array 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());
pub fn is_bool(&self) -> bool
[src]
Check if the value is a bool
pub fn is_int(&self) -> bool
[src]
Check if the value is an integer
pub fn is_float(&self) -> bool
[src]
Check if the value is a float
pub fn is_string(&self) -> bool
[src]
Check if the value is a string
pub fn is_array(&self) -> bool
[src]
Check if the value is an array
pub fn is_null(&self) -> bool
[src]
Check if the value is null
pub fn into_bool(self) -> Option<bool>
[src]
Convert the value into a bool if it is one
pub fn into_int(self) -> Option<i64>
[src]
Convert the value into a int if it is one
pub fn into_float(self) -> Option<f64>
[src]
Convert the value into a float if it is one
pub fn into_string(self) -> Option<String>
[src]
Convert the value into a string if it is one
pub fn into_hashmap(self) -> Option<HashMap<Key, Value>>
[src]
Convert the value into a hashmap if it is one
pub fn as_str(&self) -> Option<&str>
[src]
Get the value as &str if it is a string
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl<'de> Deserialize<'de> for Value
[src]
pub fn deserialize<D>(deserializer: D) -> Result<Value, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for Value
[src]
impl<'_> From<&'_ str> for Value
[src]
impl From<String> for Value
[src]
impl From<bool> for Value
[src]
impl From<f64> for Value
[src]
impl From<i64> for Value
[src]
impl<Q: ?Sized, '_> Index<&'_ Q> for Value where
Key: Borrow<Q>,
Q: Eq + Hash,
[src]
Key: Borrow<Q>,
Q: Eq + Hash,
type Output = Value
The returned type after indexing.
pub fn index(&self, index: &Q) -> &Self::Output
[src]
impl Index<Key> for Value
[src]
type Output = Value
The returned type after indexing.
pub fn index(&self, index: Key) -> &Self::Output
[src]
impl Index<i64> for Value
[src]
type Output = Value
The returned type after indexing.
pub fn index(&self, index: i64) -> &Self::Output
[src]
impl<'_> PartialEq<&'_ str> for Value
[src]
pub fn eq(&self, other: &&str) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<String> for Value
[src]
pub fn eq(&self, other: &String) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<Value> for Value
[src]
impl PartialEq<bool> for Value
[src]
pub fn eq(&self, other: &bool) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<f64> for Value
[src]
pub fn eq(&self, other: &f64) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<i64> for Value
[src]
pub fn eq(&self, other: &i64) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralPartialEq for Value
[src]
Auto Trait Implementations
impl RefUnwindSafe for Value
[src]
impl Send for Value
[src]
impl Sync for Value
[src]
impl Unpin for Value
[src]
impl UnwindSafe for Value
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,