aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-20 01:16:50 +0900
committernsfisis <nsfisis@gmail.com>2026-06-20 02:22:41 +0900
commitefec43b3b8827820cf35fe1b73d8e33f5fe84eb4 (patch)
treea62bbba72324de48be5f8e689559f8d9e288fc61 /crates/shirabe-php-shim/src
parentcac18ef73a39b4ac41fa4d6ccb753804d4c42cb7 (diff)
downloadphp-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.tar.gz
php-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.tar.zst
php-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.zip
refactor: auto-fix clippy warnings
Diffstat (limited to 'crates/shirabe-php-shim/src')
-rw-r--r--crates/shirabe-php-shim/src/lib.rs6
-rw-r--r--crates/shirabe-php-shim/src/preg.rs2
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs
index d643260..609d320 100644
--- a/crates/shirabe-php-shim/src/lib.rs
+++ b/crates/shirabe-php-shim/src/lib.rs
@@ -1459,8 +1459,8 @@ pub fn glob(_pattern: &str) -> Vec<String> {
pub fn basename(path: &str) -> String {
// PHP basename(): the trailing name component, after stripping trailing directory separators.
- let trimmed = path.trim_end_matches(|c| matches!(c, '/' | '\\'));
- match trimmed.rfind(|c| matches!(c, '/' | '\\')) {
+ let trimmed = path.trim_end_matches(['/', '\\']);
+ match trimmed.rfind(['/', '\\']) {
Some(index) => trimmed[index + 1..].to_string(),
None => trimmed.to_string(),
}
@@ -1933,7 +1933,7 @@ pub fn dirname_levels(_path: &str, _levels: i64) -> String {
// re-scanned. Empty keys are ignored.
pub fn strtr_array(s: &str, pairs: &IndexMap<String, String>) -> String {
let mut keys: Vec<&String> = pairs.keys().filter(|k| !k.is_empty()).collect();
- keys.sort_by(|a, b| b.len().cmp(&a.len()));
+ keys.sort_by_key(|k| std::cmp::Reverse(k.len()));
let bytes = s.as_bytes();
let mut result: Vec<u8> = Vec::with_capacity(bytes.len());
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs
index 46d9428..6bf8900 100644
--- a/crates/shirabe-php-shim/src/preg.rs
+++ b/crates/shirabe-php-shim/src/preg.rs
@@ -99,7 +99,7 @@ pub fn preg_match_all_set_order(
count
}
-pub fn preg_grep(pattern: &str, input: &Vec<String>) -> Vec<String> {
+pub fn preg_grep(pattern: &str, input: &[String]) -> Vec<String> {
let re = compile_php_pattern(pattern).unwrap_or_else(|e| panic!("invalid regex: {e}"));
input.iter().filter(|s| re.is_match(s)).cloned().collect()
}