From 3a7797511b4a72ba7d5dfcbeb455b461f9f643a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sun, 27 Oct 2024 19:03:22 +0100 Subject: [PATCH] Remove custom NeverOkResult trait and instead use new Rust 1.82 matching --- src/forward_traffic.rs | 3 +-- src/lib.rs | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/forward_traffic.rs b/src/forward_traffic.rs index cf08b8a..9914170 100644 --- a/src/forward_traffic.rs +++ b/src/forward_traffic.rs @@ -1,4 +1,3 @@ -use crate::NeverOkResult; use err_context::BoxedErrorExt as _; use err_context::ResultExt as _; use futures::future::select; @@ -41,7 +40,7 @@ pub async fn process_udp_over_tcp( } }; let udp2tcp = async move { - let error = process_udp2tcp(udp_in, tcp_out).await.into_error(); + let Err(error) = process_udp2tcp(udp_in, tcp_out).await; log::error!("Error: {}", error.display("\nCaused by: ")); }; diff --git a/src/lib.rs b/src/lib.rs index b0a9db4..274b9cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,15 +95,3 @@ pub use tcp_options::{ApplyTcpOptionsError, ApplyTcpOptionsErrorKind, TcpOptions /// Size of the header (in bytes) that is prepended to each datagram in the TCP stream. pub use forward_traffic::HEADER_LEN; - -/// Helper trait for `Result` types. Allows getting the `E` value -/// in a way that is guaranteed to not panic. -pub trait NeverOkResult { - fn into_error(self) -> E; -} - -impl NeverOkResult for Result { - fn into_error(self) -> E { - self.expect_err("Result can't be Ok variant") - } -}