pub enum Target<'a> {
RefMut(&'a mut Dynamic),
SharedValue {
guard: DynamicWriteLock<'a, Dynamic>,
shared_value: Dynamic,
},
TempValue(Dynamic),
Bit {
source: &'a mut Dynamic,
value: Dynamic,
bit: u8,
},
BitField {
source: &'a mut Dynamic,
value: Dynamic,
mask: INT,
shift: u8,
},
BlobByte {
source: &'a mut Dynamic,
value: Dynamic,
index: usize,
},
StringChar {
source: &'a mut Dynamic,
value: Dynamic,
index: usize,
},
StringSlice {
source: &'a mut Dynamic,
value: Dynamic,
start: usize,
end: usize,
exclusive: bool,
},
}
Expand description
(internals) A type that encapsulates a mutation target for an expression with side effects.
Exported under the internals
feature only.
This type is typically used to hold a mutable reference to the target of an indexing or property access operation.
§Example
// Normal `Dynamic` value
let mut value = Dynamic::from(42_i64);
let target: Target = value.into();
// Mutable reference to a `Dynamic` value
let mut value = Dynamic::from(42_i64);
let value_ref = &mut value;
let target: Target = value.into();
Variants§
RefMut(&'a mut Dynamic)
The target is a mutable reference to a Dynamic
.
The target is a mutable reference to a shared Dynamic
.
TempValue(Dynamic)
The target is a temporary Dynamic
value (i.e. its mutation can cause no side effects).
Bit
The target is a bit inside an INT
.
This is necessary because directly pointing to a bit inside an INT
is impossible.
Fields
BitField
The target is a range of bits inside an INT
.
This is necessary because directly pointing to a range of bits inside an INT
is impossible.
Fields
BlobByte
The target is a byte inside a Blob
.
This is necessary because directly pointing to a byte inside a BLOB is impossible.
Fields
StringChar
The target is a character inside a string.
This is necessary because directly pointing to a char
inside a String
is impossible.
Fields
StringSlice
Implementations§
source§impl<'a> Target<'a>
impl<'a> Target<'a>
sourcepub const fn is_temp_value(&self) -> bool
pub const fn is_temp_value(&self) -> bool
Is the Target
a temp value?
Is the Target
a shared value?
sourcepub fn take_or_clone(self) -> Dynamic
pub fn take_or_clone(self) -> Dynamic
sourcepub fn take_ref(self) -> Option<&'a mut Dynamic>
pub fn take_ref(self) -> Option<&'a mut Dynamic>
Take a &mut Dynamic
reference from the Target
.
sourcepub fn into_owned(self) -> Self
pub fn into_owned(self) -> Self
Convert a shared or reference Target
into a target with an owned value.
sourcepub fn propagate_changed_value(
&mut self,
_pos: Position
) -> Result<(), Box<EvalAltResult>>
pub fn propagate_changed_value( &mut self, _pos: Position ) -> Result<(), Box<EvalAltResult>>
Propagate a changed value back to the original source. This has no effect for direct references.