Skip to content

Commit 089491a

Browse files
committed
Merge branch 'new-pattern-matching-on-infallible'
2 parents 24b2e25 + e0c6b2e commit 089491a

File tree

5 files changed

+5
-20
lines changed

5 files changed

+5
-20
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- os: ubuntu-latest
7070
# MSRV. Not considered breaking when this has to be bumped.
7171
# But update `rust-version` in `Cargo.toml`
72-
rust: 1.80.0
72+
rust: 1.82.0
7373
runs-on: ${{ matrix.os }}
7474
steps:
7575
- uses: actions/checkout@v4

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
66
description = "Tunnel UDP traffic inside a TCP stream. Each datagram is prefixed with a 16 bit unsigned integer containing the length"
77
repository = "https://github.com/mullvad/udp-over-tcp"
88
edition = "2021"
9-
rust-version = "1.80.0"
9+
rust-version = "1.82.0"
1010
publish = false
1111

1212
[[bin]]

src/bin/tcp2udp.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clap::Parser;
44
use err_context::ErrorExt as _;
55
use std::num::NonZeroU8;
66

7-
use udp_over_tcp::{tcp2udp, NeverOkResult};
7+
use udp_over_tcp::tcp2udp;
88

99
#[derive(Debug, Parser)]
1010
#[command(
@@ -30,9 +30,7 @@ fn main() {
3030

3131
let runtime = create_runtime(options.threads);
3232

33-
let error = runtime
34-
.block_on(tcp2udp::run(options.tcp2udp_options))
35-
.into_error();
33+
let Err(error) = runtime.block_on(tcp2udp::run(options.tcp2udp_options));
3634
log::error!("Error: {}", error.display("\nCaused by: "));
3735
std::process::exit(1);
3836
}

src/forward_traffic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::NeverOkResult;
21
use err_context::BoxedErrorExt as _;
32
use err_context::ResultExt as _;
43
use futures::future::select;
@@ -41,7 +40,7 @@ pub async fn process_udp_over_tcp(
4140
}
4241
};
4342
let udp2tcp = async move {
44-
let error = process_udp2tcp(udp_in, tcp_out).await.into_error();
43+
let Err(error) = process_udp2tcp(udp_in, tcp_out).await;
4544
log::error!("Error: {}", error.display("\nCaused by: "));
4645
};
4746

src/lib.rs

-12
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,3 @@ pub use tcp_options::{ApplyTcpOptionsError, ApplyTcpOptionsErrorKind, TcpOptions
9595

9696
/// Size of the header (in bytes) that is prepended to each datagram in the TCP stream.
9797
pub use forward_traffic::HEADER_LEN;
98-
99-
/// Helper trait for `Result<Infallible, E>` types. Allows getting the `E` value
100-
/// in a way that is guaranteed to not panic.
101-
pub trait NeverOkResult<E> {
102-
fn into_error(self) -> E;
103-
}
104-
105-
impl<E> NeverOkResult<E> for Result<std::convert::Infallible, E> {
106-
fn into_error(self) -> E {
107-
self.expect_err("Result<Infallible, _> can't be Ok variant")
108-
}
109-
}

0 commit comments

Comments
 (0)