diff --git a/macros/src/throws.rs b/macros/src/throws.rs index 27acd2d..56d5b43 100644 --- a/macros/src/throws.rs +++ b/macros/src/throws.rs @@ -146,7 +146,7 @@ fn make_fn_block(ty: &syn::Type, inner: &syn::Block) -> syn::Block { let __ret = { #inner }; #[allow(unreachable_code)] - <#ty as ::culpa::__internal::_Succeed>::from_ok(__ret) + ::core::iter::Iterator::try_fold::<_, _, #ty>(&mut ::core::iter::empty::<::core::convert::Infallible>(), __ret, |_, x| match x {}) } }}) .unwrap(); @@ -155,9 +155,9 @@ fn make_fn_block(ty: &syn::Type, inner: &syn::Block) -> syn::Block { } fn ok(ty: &syn::Type, expr: &syn::Expr) -> syn::Expr { - syn::parse2(quote::quote!(<#ty as ::culpa::__internal::_Succeed>::from_ok(#expr))).unwrap() + syn::parse2(quote::quote!(::core::iter::Iterator::try_fold::<_, _, #ty>(&mut ::core::iter::empty::<::core::convert::Infallible>(), #expr, |_, x| match x {}))).unwrap() } fn ok_unit(ty: &syn::Type) -> syn::Expr { - syn::parse2(quote::quote!(<#ty as ::culpa::__internal::_Succeed>::from_ok(()))).unwrap() + syn::parse2(quote::quote!(::core::iter::Iterator::try_fold::<_, _, #ty>(&mut ::core::iter::empty::<::core::convert::Infallible>(), (), |_, x| match x {}))).unwrap() } diff --git a/src/lib.rs b/src/lib.rs index b246601..8517628 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,11 +109,6 @@ macro_rules! throw { #[doc(hidden)] pub mod __internal { - pub trait _Succeed { - type Ok; - fn from_ok(ok: Self::Ok) -> Self; - } - pub trait _Throw { type Error; fn from_error(error: Self::Error) -> Self; @@ -122,13 +117,6 @@ pub mod __internal { mod stable { use core::task::Poll; - impl super::_Succeed for Result { - type Ok = T; - fn from_ok(ok: T) -> Self { - Ok(ok) - } - } - impl super::_Throw for Result { type Error = E; fn from_error(error: Self::Error) -> Self { @@ -136,17 +124,6 @@ pub mod __internal { } } - impl super::_Succeed for Poll> { - type Ok = Poll; - - fn from_ok(ok: Self::Ok) -> Self { - match ok { - Poll::Ready(ok) => Poll::Ready(Ok(ok)), - Poll::Pending => Poll::Pending, - } - } - } - impl super::_Throw for Poll> { type Error = E; @@ -155,18 +132,6 @@ pub mod __internal { } } - impl super::_Succeed for Poll>> { - type Ok = Poll>; - - fn from_ok(ok: Self::Ok) -> Self { - match ok { - Poll::Ready(Some(ok)) => Poll::Ready(Some(Ok(ok))), - Poll::Ready(None) => Poll::Ready(None), - Poll::Pending => Poll::Pending, - } - } - } - impl super::_Throw for Poll>> { type Error = E; @@ -174,14 +139,6 @@ pub mod __internal { Poll::Ready(Some(Err(error))) } } - - impl super::_Succeed for Option { - type Ok = T; - - fn from_ok(ok: Self::Ok) -> Self { - Some(ok) - } - } } }