chore: update Rust to 2024 edition (#2066)

This commit is contained in:
Luna Yao
2026-04-09 18:22:12 +02:00
committed by GitHub
parent a8feb9ac2b
commit a879dd1b14
158 changed files with 1327 additions and 1231 deletions
+12 -13
View File
@@ -4,10 +4,10 @@ use std::{
};
use anyhow::Context;
use base64::{prelude::BASE64_STANDARD, Engine as _};
use base64::{Engine as _, prelude::BASE64_STANDARD};
use strum::VariantArray;
use crate::tunnel::{packet_def::CompressorAlgo, IpScheme};
use crate::tunnel::{IpScheme, packet_def::CompressorAlgo};
include!(concat!(env!("OUT_DIR"), "/common.rs"));
@@ -288,18 +288,17 @@ impl fmt::Display for Url {
fn split_tunnel_scheme(raw_scheme: &str) -> Option<(&str, &'static str, bool)> {
for scheme in IpScheme::VARIANTS {
let scheme: &'static str = scheme.into();
if let Some(base) = raw_scheme.strip_suffix('6') {
if let Some(prefix) = base.strip_suffix(scheme) {
if prefix.is_empty() || prefix.ends_with('-') {
return Some((prefix, scheme, true));
}
}
if let Some(base) = raw_scheme.strip_suffix('6')
&& let Some(prefix) = base.strip_suffix(scheme)
&& (prefix.is_empty() || prefix.ends_with('-'))
{
return Some((prefix, scheme, true));
}
if let Some(prefix) = raw_scheme.strip_suffix(scheme) {
if prefix.is_empty() || prefix.ends_with('-') {
return Some((prefix, scheme, false));
}
if let Some(prefix) = raw_scheme.strip_suffix(scheme)
&& (prefix.is_empty() || prefix.ends_with('-'))
{
return Some((prefix, scheme, false));
}
}
@@ -532,7 +531,7 @@ impl SecureModeConfig {
#[cfg(test)]
mod tests {
use super::{normalize_tunnel_url, TunnelInfo, Url};
use super::{TunnelInfo, Url, normalize_tunnel_url};
fn assert_ipv6_tunnel_normalization(scheme: &str, port: u16) {
let expected = format!("{scheme}6://[2001:db8::1]:{port}");