[−][src]Struct starlark::values::Value
A value in Starlark.
This is a wrapper around a TypedValue which is cheap to clone and safe to pass around.
Methods
impl Value
[src]
pub fn convert_index(&self, len: i64) -> Result<i64, ValueError>
[src]
Macro to parse the index for at/set_at methods.
Return an i64
from self corresponding to the index recenterd between 0 and len.
Raise the correct errors if the value is not numeric or the index is out of bound.
Examples
Value::new(6).convert_index(7).unwrap() == 6 Value::new(-1).convert_index(7).unwrap() == 6
The following examples would return an error
Value::from("a").convert_index(7) == Err(ValueError::IncorrectParameterType) Value::new(8).convert_index(7) == Err(ValueError::IndexOutOfBound(8)) // 8 > 7 = len Value::new(-8).convert_index(7) == Err(ValueError::IndexOutOfBound(-1)) // -8 + 7 = -1 < 0
impl Value
[src]
pub fn new<T: TypedValue>(t: T) -> Value
[src]
Create a new Value
from a static value.
pub fn clone_for_container<T: TypedValue>(
&self,
container: &T
) -> Result<Value, ValueError>
[src]
&self,
container: &T
) -> Result<Value, ValueError>
Clone for inserting into the other container, using weak reference if we do a recursive insertion.
pub fn clone_for_container_value(
&self,
other: &Value
) -> Result<Value, ValueError>
[src]
&self,
other: &Value
) -> Result<Value, ValueError>
pub fn is_descendant_value(&self, other: &Value) -> bool
[src]
Determine if the value pointed by other is a descendant of self
pub fn is_descendant(&self, other: DataPtr) -> bool
[src]
pub fn data_ptr(&self) -> DataPtr
[src]
Object data pointer.
pub fn function_id(&self) -> FunctionId
[src]
Function id used to detect recursion.
impl Value
[src]
pub fn freeze(&mut self)
[src]
pub fn to_str_impl(&self, buf: &mut String) -> Result
[src]
pub fn to_str(&self) -> String
[src]
pub fn to_rc_string(&self) -> RcString
[src]
pub fn to_repr_impl(&self, buf: &mut String) -> Result
[src]
pub fn to_repr(&self) -> String
[src]
pub fn get_type(&self) -> &'static str
[src]
pub fn to_bool(&self) -> bool
[src]
pub fn to_int(&self) -> Result<i64, ValueError>
[src]
pub fn get_hash(&self) -> Result<u64, ValueError>
[src]
pub fn equals(&self, other: &Value) -> Result<bool, ValueError>
[src]
pub fn compare(&self, other: &Value) -> Result<Ordering, ValueError>
[src]
pub fn call(
&self,
call_stack: &mut CallStack,
type_values: &TypeValues,
positional: Vec<Value>,
named: LinkedHashMap<RcString, Value>,
args: Option<Value>,
kwargs: Option<Value>
) -> ValueResult
[src]
&self,
call_stack: &mut CallStack,
type_values: &TypeValues,
positional: Vec<Value>,
named: LinkedHashMap<RcString, Value>,
args: Option<Value>,
kwargs: Option<Value>
) -> ValueResult
pub fn at(&self, index: Value) -> ValueResult
[src]
pub fn set_at(
&mut self,
index: Value,
new_value: Value
) -> Result<(), ValueError>
[src]
&mut self,
index: Value,
new_value: Value
) -> Result<(), ValueError>
pub fn slice(
&self,
start: Option<Value>,
stop: Option<Value>,
stride: Option<Value>
) -> ValueResult
[src]
&self,
start: Option<Value>,
stop: Option<Value>,
stride: Option<Value>
) -> ValueResult
pub fn iter(&self) -> Result<RefIterable, ValueError>
[src]
pub fn to_vec(&self) -> Result<Vec<Value>, ValueError>
[src]
pub fn length(&self) -> Result<i64, ValueError>
[src]
pub fn get_attr(&self, attribute: &str) -> ValueResult
[src]
pub fn has_attr(&self, attribute: &str) -> Result<bool, ValueError>
[src]
pub fn set_attr(
&mut self,
attribute: &str,
new_value: Value
) -> Result<(), ValueError>
[src]
&mut self,
attribute: &str,
new_value: Value
) -> Result<(), ValueError>
pub fn dir_attr(&self) -> Result<Vec<RcString>, ValueError>
[src]
pub fn contains(&self, other: &Value) -> Result<bool, ValueError>
[src]
pub fn plus(&self) -> ValueResult
[src]
pub fn minus(&self) -> ValueResult
[src]
pub fn add(&self, other: Value) -> ValueResult
[src]
pub fn sub(&self, other: Value) -> ValueResult
[src]
pub fn mul(&self, other: Value) -> ValueResult
[src]
pub fn percent(&self, other: Value) -> ValueResult
[src]
pub fn div(&self, other: Value) -> ValueResult
[src]
pub fn floor_div(&self, other: Value) -> ValueResult
[src]
pub fn pipe(&self, other: Value) -> ValueResult
[src]
impl Value
[src]
pub fn downcast_ref<T: TypedValue>(&self) -> Option<ObjectRef<T>>
[src]
Get a reference to underlying data or None
if contained object has different type than requested.
This function panics if the Value
is borrowed mutably.
pub fn downcast_mut<T: TypedValue<Holder = Mutable<T>>>(
&self
) -> Result<Option<ObjectRefMut<T>>, ValueError>
[src]
&self
) -> Result<Option<ObjectRefMut<T>>, ValueError>
Get a mutable reference to underlying data or None
if contained object has different type than requested.
This function panics if the Value
is borrowed.
Error is returned if the value is frozen or frozen for iteration.
pub fn downcast_rc_str(&self) -> Option<&RcString>
[src]
downcast_ref
cannot be used, because we are obtaining RcString
, not String
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Display for Value
[src]
impl Eq for Value
[src]
impl<'a> From<&'a str> for Value
[src]
impl From<()> for Value
[src]
impl<T: Into<Value> + Clone> From<(T,)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone, T6: Into<Value> + Clone, T7: Into<Value> + Clone, T8: Into<Value> + Clone, T9: Into<Value> + Clone, T10: Into<Value> + Clone> From<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone, T6: Into<Value> + Clone, T7: Into<Value> + Clone, T8: Into<Value> + Clone, T9: Into<Value> + Clone> From<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone, T6: Into<Value> + Clone, T7: Into<Value> + Clone, T8: Into<Value> + Clone> From<(T1, T2, T3, T4, T5, T6, T7, T8)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone, T6: Into<Value> + Clone, T7: Into<Value> + Clone> From<(T1, T2, T3, T4, T5, T6, T7)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone, T6: Into<Value> + Clone> From<(T1, T2, T3, T4, T5, T6)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone, T5: Into<Value> + Clone> From<(T1, T2, T3, T4, T5)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone, T4: Into<Value> + Clone> From<(T1, T2, T3, T4)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone, T3: Into<Value> + Clone> From<(T1, T2, T3)> for Value
[src]
impl<T1: Into<Value> + Clone, T2: Into<Value> + Clone> From<(T1, T2)> for Value
[src]
impl From<FunctionArg> for Value
[src]
fn from(a: FunctionArg) -> Value
[src]
impl From<HashedValue> for Value
[src]
fn from(key: HashedValue) -> Value
[src]
impl From<NoneType> for Value
[src]
impl From<RcString> for Value
[src]
impl From<String> for Value
[src]
impl From<Value> for DataPtr
[src]
impl<T: Into<Value>> From<Vec<T>> for Value
[src]
impl From<bool> for Value
[src]
impl From<i16> for Value
[src]
impl From<i32> for Value
[src]
impl From<i64> for Value
[src]
impl From<i8> for Value
[src]
impl From<isize> for Value
[src]
impl From<u16> for Value
[src]
impl From<u32> for Value
[src]
impl From<u64> for Value
[src]
impl From<u8> for Value
[src]
impl From<usize> for Value
[src]
impl PartialEq<Value> for Value
[src]
impl<T1: Into<Value> + Eq + Hash + Clone, T2: Into<Value> + Eq + Clone> TryFrom<HashMap<T1, T2, RandomState>> for Value
[src]
type Error = ValueError
The type returned in the event of a conversion error.
fn try_from(a: HashMap<T1, T2>) -> Result<Value, ValueError>
[src]
impl<T1: Into<Value> + Eq + Hash + Clone, T2: Into<Value> + Eq + Clone> TryFrom<LinkedHashMap<T1, T2, RandomState>> for Value
[src]
type Error = ValueError
The type returned in the event of a conversion error.
fn try_from(a: LinkedHashMap<T1, T2>) -> Result<Value, ValueError>
[src]
impl TryParamConvertFromValue for Value
[src]
fn try_from(source: Value) -> Result<Self, ValueError>
[src]
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
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,
fn borrow_mut(&mut self) -> &mut T
[src]
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.
fn to_owned(&self) -> T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TryParamConvertFromValue for T where
T: 'static + TypedValue + Clone,
[src]
T: 'static + TypedValue + Clone,