Enum apollo_compiler::database::hir::Value
source · pub enum Value {
Variable(Variable),
Int {
value: Float,
loc: HirNodeLocation,
},
Float {
value: Float,
loc: HirNodeLocation,
},
String {
value: String,
loc: HirNodeLocation,
},
Boolean {
value: bool,
loc: HirNodeLocation,
},
Null {
loc: HirNodeLocation,
},
Enum {
value: Name,
loc: HirNodeLocation,
},
List {
value: Vec<Value>,
loc: HirNodeLocation,
},
Object {
value: Vec<(Name, Value)>,
loc: HirNodeLocation,
},
}
Variants§
Implementations§
source§impl Value
impl Value
sourcepub fn is_same_value(&self, other: &Value) -> bool
pub fn is_same_value(&self, other: &Value) -> bool
Returns true
if other
represents the same value as self
. This is different from the
Eq
implementation as it ignores location information.
sourcepub fn loc(&self) -> HirNodeLocation
pub fn loc(&self) -> HirNodeLocation
Get current value’s location.
pub fn variables(&self) -> Vec<Variable>
pub fn kind(&self) -> &str
sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Returns true
if the value is Variable
.
sourcepub fn as_i32(&self) -> Option<i32>
pub fn as_i32(&self) -> Option<i32>
Returns an i32
if the value is a number and can be represented as an i32.
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns an f64
if the value is a number and can be represented as an f64.
sourcepub fn as_list(&self) -> Option<&Vec<Value>>
pub fn as_list(&self) -> Option<&Vec<Value>>
Returns the inner list if the value is a List type.
sourcepub fn as_object(&self) -> Option<&Vec<(Name, Value)>>
pub fn as_object(&self) -> Option<&Vec<(Name, Value)>>
Returns a keys/values list if the value is an input object.
sourcepub fn as_variable(&self) -> Option<&Variable>
pub fn as_variable(&self) -> Option<&Variable>
Returns the hir::Variable
if the value is a variable reference.
Trait Implementations§
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
impl Eq for Value
impl StructuralEq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.