Replace unnecessary exchange util.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -5,11 +5,10 @@
|
||||
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
mem::replace,
|
||||
sync::{Mutex, OnceLock},
|
||||
};
|
||||
|
||||
use crate::utils::exchange;
|
||||
|
||||
// Capture rustc version during compilation.
|
||||
tuwunel_macros::rustc_version! {}
|
||||
|
||||
@@ -54,7 +53,7 @@ fn append_features(features: &mut Vec<&'static str>, flags: &[&'static str]) {
|
||||
for flag in flags {
|
||||
let is_cfg = *flag == "--cfg";
|
||||
let is_feature = flag.starts_with("feature=");
|
||||
if exchange(&mut next_is_cfg, is_cfg) && is_feature {
|
||||
if replace(&mut next_is_cfg, is_cfg) && is_feature {
|
||||
if let Some(feature) = flag
|
||||
.split_once('=')
|
||||
.map(|(_, feature)| feature.trim_matches('"'))
|
||||
|
||||
@@ -42,9 +42,6 @@ pub use self::{
|
||||
},
|
||||
};
|
||||
|
||||
#[inline]
|
||||
pub fn exchange<T>(state: &mut T, source: T) -> T { std::mem::replace(state, source) }
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! extract_variant {
|
||||
( $e:expr_2021, $( $variant:path )|* ) => {
|
||||
|
||||
@@ -4,8 +4,10 @@ mod tests;
|
||||
mod unquote;
|
||||
mod unquoted;
|
||||
|
||||
use std::mem::replace;
|
||||
|
||||
pub use self::{between::Between, split::SplitInfallible, unquote::Unquote, unquoted::Unquoted};
|
||||
use crate::{Result, smallstr::SmallString, utils::exchange};
|
||||
use crate::{Result, smallstr::SmallString};
|
||||
|
||||
pub const EMPTY: &str = "";
|
||||
|
||||
@@ -76,7 +78,7 @@ where
|
||||
.map(char::from)
|
||||
.try_for_each(|ch| {
|
||||
let m = ch.is_ascii_uppercase();
|
||||
let s = exchange(&mut state, !m);
|
||||
let s = replace(&mut state, !m);
|
||||
if m && s {
|
||||
output.write_char('_')?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user