From 7cdf52544c611b05c6365595a8ae713672706b67 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Fri, 28 Aug 2026 17:24:44 +0700 Subject: [PATCH] feat!: rename CorexError to MytheclipseError Complete the mytheclipse rebranding: the public error type now uses the mytheclipse name. Breaking API change (CorexError -> MytheclipseError), hence the major version bump. BREAKING CHANGE: CorexError is renamed to MytheclipseError. --- examples/main.rs | 2 +- src/compute.rs | 12 ++++++------ src/error.rs | 6 +++--- src/lib.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/main.rs b/examples/main.rs index 80c252e..ed4668e 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -18,7 +18,7 @@ async fn main() { let sum_result = mytheclipse::compute(|| (1..=1_000u64).sum::()); - let panic_result: Result = mytheclipse::compute(|| { + let panic_result: Result = mytheclipse::compute(|| { panic!("intentional panic to demonstrate isolation"); }); diff --git a/src/compute.rs b/src/compute.rs index e853473..d00fcbb 100644 --- a/src/compute.rs +++ b/src/compute.rs @@ -3,12 +3,12 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; use crate::context::context; -use crate::error::CorexError; +use crate::error::MytheclipseError; /// Runs `f` on the global compute thread pool and returns its result. /// /// If `f` panics, the panic is caught and converted into -/// [`CorexError::ComputePanic`] instead of unwinding across the pool +/// [`MytheclipseError::ComputePanic`] instead of unwinding across the pool /// boundary or poisoning the pool; subsequent calls to [`compute`] continue /// to work normally. /// @@ -23,7 +23,7 @@ use crate::error::CorexError; /// captured by mutable reference: if `f` panics partway through mutating a /// captured `&mut T`, that `T` may be left in an inconsistent state from /// the caller's perspective. -pub fn compute(f: F) -> Result +pub fn compute(f: F) -> Result where F: FnOnce() -> R + Send, R: Send, @@ -32,7 +32,7 @@ where context() .compute_pool .install(move || catch_unwind(wrapped)) - .map_err(|payload| CorexError::ComputePanic(panic_payload_to_string(payload))) + .map_err(|payload| MytheclipseError::ComputePanic(panic_payload_to_string(payload))) } fn panic_payload_to_string(payload: Box) -> String { @@ -51,8 +51,8 @@ mod tests { #[test] fn compute_panic_is_isolated_and_pool_survives() { - let panicked: Result = compute(|| panic!("boom")); - assert!(matches!(panicked, Err(CorexError::ComputePanic(_)))); + let panicked: Result = compute(|| panic!("boom")); + assert!(matches!(panicked, Err(MytheclipseError::ComputePanic(_)))); let recovered = compute(|| 1 + 1); assert_eq!(recovered.unwrap(), 2); diff --git a/src/error.rs b/src/error.rs index 34c3266..e4015e6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,7 +7,7 @@ /// wildcard arm. #[non_exhaustive] #[derive(Debug)] -pub enum CorexError { +pub enum MytheclipseError { /// A closure submitted to [`crate::compute::compute`] panicked. /// /// The contained string is a best-effort rendering of the panic @@ -15,7 +15,7 @@ pub enum CorexError { ComputePanic(String), } -impl std::fmt::Display for CorexError { +impl std::fmt::Display for MytheclipseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::ComputePanic(message) => { @@ -25,4 +25,4 @@ impl std::fmt::Display for CorexError { } } -impl std::error::Error for CorexError {} +impl std::error::Error for MytheclipseError {} diff --git a/src/lib.rs b/src/lib.rs index 8de2566..13eef40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,7 +30,7 @@ pub mod bg; pub use context::{context, EngineContext}; #[cfg(feature = "compute")] -pub use error::CorexError; +pub use error::MytheclipseError; #[cfg(feature = "io")] pub use io::spawn_io;