pub struct ConstantPool { /* private fields */ }
Expand description
Maintains the mapping between a constant handle (i.e. Constant
) and
its constant data (i.e. ConstantData
).
Implementations§
Source§impl ConstantPool
impl ConstantPool
Sourcepub fn insert(&mut self, constant_value: ConstantData) -> Constant
pub fn insert(&mut self, constant_value: ConstantData) -> Constant
Insert constant data into the pool, returning a handle for later referencing; when constant data is inserted that is a duplicate of previous constant data, the existing handle will be returned.
Sourcepub fn get(&self, constant_handle: Constant) -> &ConstantData
pub fn get(&self, constant_handle: Constant) -> &ConstantData
Retrieve the constant data given a handle.
Sourcepub fn set(&mut self, constant_handle: Constant, constant_value: ConstantData)
pub fn set(&mut self, constant_handle: Constant, constant_value: ConstantData)
Link a constant handle to its value. This does not de-duplicate data but does avoid
replacing any existing constant values. use set
to tie a specific const42
to its value;
use insert
to add a value and return the next available const
entity.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Constant, &ConstantData)>
pub fn iter(&self) -> impl Iterator<Item = (&Constant, &ConstantData)>
Iterate over the constants in insertion order.
Sourcepub fn entries_mut(&mut self) -> impl Iterator<Item = &mut ConstantData>
pub fn entries_mut(&mut self) -> impl Iterator<Item = &mut ConstantData>
Iterate over mutable entries in the constant pool in insertion order.
Trait Implementations§
Source§impl Clone for ConstantPool
impl Clone for ConstantPool
Source§fn clone(&self) -> ConstantPool
fn clone(&self) -> ConstantPool
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Hash for ConstantPool
impl Hash for ConstantPool
Source§impl PartialEq for ConstantPool
impl PartialEq for ConstantPool
impl StructuralPartialEq for ConstantPool
Auto Trait Implementations§
impl Freeze for ConstantPool
impl RefUnwindSafe for ConstantPool
impl Send for ConstantPool
impl Sync for ConstantPool
impl Unpin for ConstantPool
impl UnwindSafe for ConstantPool
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