Skip to content

Commit

Permalink
Merge pull request #110 from macournoyer/cloneable-error
Browse files Browse the repository at this point in the history
Make Error and OpaqueError cloneable
  • Loading branch information
matsadler authored May 21, 2024
2 parents 324f57e + 6793884 commit 84d917b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Ruby {
pub type Result<T> = std::result::Result<T, Error>;

/// The possible types of [`Error`].
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum ErrorType {
/// An interrupt, such as `break` or `throw`.
Jump(Tag),
Expand All @@ -106,7 +106,7 @@ pub enum ErrorType {
}

/// Wrapper type for Ruby `Exception`s or other interrupts.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Error(ErrorType);

impl Error {
Expand Down Expand Up @@ -350,6 +350,7 @@ impl IntoError for Error {
/// Note that `OpaqueError` contains a Ruby value, so must be kept on the stack
/// of a Ruby thread to prevent it from being Garbage Collected (or otherwise
/// protected from premature GC).
#[derive(Clone)]
pub struct OpaqueError(ErrorType);

unsafe impl Send for OpaqueError {}
Expand Down Expand Up @@ -394,7 +395,7 @@ impl IntoError for OpaqueError {

/// The state of a call to Ruby exiting early, interrupting the normal flow
/// of code.
#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
#[repr(i32)]
pub enum Tag {
// None = 0,
Expand Down

0 comments on commit 84d917b

Please sign in to comment.