pub struct BlockCall { /* private fields */ }
Expand description
A pair of a Block and its arguments, stored in a single EntityList internally.
NOTE: We don’t expose either value_to_block or block_to_value outside of this module because this operation is not generally safe. However, as the two share the same underlying layout, they can be stored in the same value pool.
BlockCall makes use of this shared layout by storing all of its contents (a block and its argument) in a single EntityList. This is a bit better than introducing a new entity type for the pair of a block name and the arguments entity list, as we don’t pay any indirection penalty to get to the argument values – they’re stored in-line with the block in the same list.
The BlockCall::new function guarantees this layout by requiring a block argument that’s written in as the first element of the EntityList. Any subsequent entries are always assumed to be real Values.
Implementations§
Source§impl BlockCall
impl BlockCall
Sourcepub fn new(block: Block, args: &[Value], pool: &mut ValueListPool) -> Self
pub fn new(block: Block, args: &[Value], pool: &mut ValueListPool) -> Self
Construct a BlockCall with the given block and arguments.
Sourcepub fn block(&self, pool: &ValueListPool) -> Block
pub fn block(&self, pool: &ValueListPool) -> Block
Return the block for this BlockCall.
Sourcepub fn set_block(&mut self, block: Block, pool: &mut ValueListPool)
pub fn set_block(&mut self, block: Block, pool: &mut ValueListPool)
Replace the block for this BlockCall.
Sourcepub fn append_argument(&mut self, arg: Value, pool: &mut ValueListPool)
pub fn append_argument(&mut self, arg: Value, pool: &mut ValueListPool)
Append an argument to the block args.
Sourcepub fn args_slice<'a>(&self, pool: &'a ValueListPool) -> &'a [Value]
pub fn args_slice<'a>(&self, pool: &'a ValueListPool) -> &'a [Value]
Return a slice for the arguments of this block.
Sourcepub fn args_slice_mut<'a>(
&'a mut self,
pool: &'a mut ValueListPool,
) -> &'a mut [Value]
pub fn args_slice_mut<'a>( &'a mut self, pool: &'a mut ValueListPool, ) -> &'a mut [Value]
Return a slice for the arguments of this block.
Sourcepub fn remove(&mut self, ix: usize, pool: &mut ValueListPool)
pub fn remove(&mut self, ix: usize, pool: &mut ValueListPool)
Remove the argument at ix from the argument list.
Sourcepub fn clear(&mut self, pool: &mut ValueListPool)
pub fn clear(&mut self, pool: &mut ValueListPool)
Clear out the arguments list.
Sourcepub fn extend<I>(&mut self, elements: I, pool: &mut ValueListPool)where
I: IntoIterator<Item = Value>,
pub fn extend<I>(&mut self, elements: I, pool: &mut ValueListPool)where
I: IntoIterator<Item = Value>,
Appends multiple elements to the arguments.
Sourcepub fn display<'a>(&self, pool: &'a ValueListPool) -> DisplayBlockCall<'a>
pub fn display<'a>(&self, pool: &'a ValueListPool) -> DisplayBlockCall<'a>
Return a value that can display this block call.
Sourcepub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
pub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
Deep-clone the underlying list in the same pool. The returned list will have identical contents but changes to this list will not change its contents or vice-versa.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BlockCall
impl<'de> Deserialize<'de> for BlockCall
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for BlockCall
impl Eq for BlockCall
impl StructuralPartialEq for BlockCall
Auto Trait Implementations§
impl Freeze for BlockCall
impl RefUnwindSafe for BlockCall
impl Send for BlockCall
impl Sync for BlockCall
impl Unpin for BlockCall
impl UnwindSafe for BlockCall
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.