Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/compiler-core/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bitflags::bitflags;
use core::{
cell::UnsafeCell,
hash, mem,
ops::{Deref, Index, IndexMut},
ops::{Deref, DerefMut, Index, IndexMut},
sync::atomic::{AtomicU8, AtomicU16, AtomicUsize, Ordering},
};
use itertools::Itertools;
Expand Down Expand Up @@ -383,6 +383,12 @@ impl<C: Constant> Deref for Constants<C> {
}
}

impl<C: Constant> DerefMut for Constants<C> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl<C: Constant> Index<oparg::ConstIdx> for Constants<C> {
type Output = C;

Expand All @@ -391,6 +397,12 @@ impl<C: Constant> Index<oparg::ConstIdx> for Constants<C> {
}
}

impl<C: Constant> IndexMut<oparg::ConstIdx> for Constants<C> {
fn index_mut(&mut self, consti: oparg::ConstIdx) -> &mut Self::Output {
&mut self.0[consti.as_usize()]
}
}

impl<C: Constant> FromIterator<C> for Constants<C> {
fn from_iter<T: IntoIterator<Item = C>>(iter: T) -> Self {
Self(iter.into_iter().collect())
Expand Down
Loading