Skip to content

Commit

Permalink
Remove custom NeverOkResult trait and instead use new Rust 1.82 matching
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Oct 27, 2024
1 parent 24b2e25 commit 3a77975
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
3 changes: 1 addition & 2 deletions src/forward_traffic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::NeverOkResult;
use err_context::BoxedErrorExt as _;
use err_context::ResultExt as _;
use futures::future::select;
Expand Down Expand Up @@ -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: "));
};

Expand Down
12 changes: 0 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Infallible, E>` types. Allows getting the `E` value
/// in a way that is guaranteed to not panic.
pub trait NeverOkResult<E> {
fn into_error(self) -> E;
}

impl<E> NeverOkResult<E> for Result<std::convert::Infallible, E> {
fn into_error(self) -> E {
self.expect_err("Result<Infallible, _> can't be Ok variant")
}
}

0 comments on commit 3a77975

Please sign in to comment.