pub struct BlockCall { /* private fields */ }
Expand description
A pair of a Block and its arguments, stored in a single EntityList internally.
Block arguments are semantically a BlockArg
.
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: impl Iterator<Item = BlockArg>,
pool: &mut ValueListPool,
) -> Self
pub fn new( block: Block, args: impl Iterator<Item = BlockArg>, 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: impl Into<BlockArg>,
pool: &mut ValueListPool,
)
pub fn append_argument( &mut self, arg: impl Into<BlockArg>, pool: &mut ValueListPool, )
Append an argument to the block args.
Sourcepub fn len(&self, pool: &ValueListPool) -> usize
pub fn len(&self, pool: &ValueListPool) -> usize
Return the length of the argument list.
Sourcepub fn args<'a>(
&self,
pool: &'a ValueListPool,
) -> impl ExactSizeIterator<Item = BlockArg> + DoubleEndedIterator<Item = BlockArg> + use<'a>
pub fn args<'a>( &self, pool: &'a ValueListPool, ) -> impl ExactSizeIterator<Item = BlockArg> + DoubleEndedIterator<Item = BlockArg> + use<'a>
Return an iterator over the arguments of this block.
Sourcepub fn update_args<F: FnMut(BlockArg) -> BlockArg>(
&mut self,
pool: &mut ValueListPool,
f: F,
)
pub fn update_args<F: FnMut(BlockArg) -> BlockArg>( &mut self, pool: &mut ValueListPool, f: F, )
Traverse the arguments with a closure that can mutate them.
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, T>(&mut self, elements: I, pool: &mut ValueListPool)
pub fn extend<I, T>(&mut self, elements: I, pool: &mut ValueListPool)
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.