FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use `num_enum` crate for oparg types by ShaharNaveh · Pull Request #6980 · RustPython/RustPython · GitHub

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/compiler-core/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bitflags = { workspace = true }
itertools = { workspace = true }
malachite-bigint = { workspace = true }
num-complex = { workspace = true }
num_enum = { workspace = true }

lz4_flex = "0.12"

Expand Down
6 changes: 3 additions & 3 deletions crates/compiler-core/src/bytecode/instruction.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ impl<T: OpArgType> Arg<T> {

#[inline]
pub fn new(arg: T) -> (Self, OpArg) {
(Self(PhantomData), OpArg(arg.to_op_arg()))
(Self(PhantomData), OpArg(arg.into()))
}

#[inline]
Expand All @@ -1267,15 +1267,15 @@ impl<T: OpArgType> Arg<T> {

#[inline(always)]
pub fn try_get(self, arg: OpArg) -> Result<T, MarshalError> {
T::from_op_arg(arg.0)
T::try_from(arg.0).map_err(|_| MarshalError::InvalidBytecode)
}

/// # Safety
/// T::from_op_arg(self) must succeed
#[inline(always)]
pub unsafe fn get_unchecked(self, arg: OpArg) -> T {
// SAFETY: requirements forwarded from caller
unsafe { T::from_op_arg(arg.0).unwrap_unchecked() }
unsafe { T::try_from(arg.0).unwrap_unchecked() }
}
}

Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL