diff --git a/fish-rust/src/flog.rs b/fish-rust/src/flog.rs index ca60c8f7b..9add0b6cd 100644 --- a/fish-rust/src/flog.rs +++ b/fish-rust/src/flog.rs @@ -1,6 +1,7 @@ use crate::ffi::{get_flog_file_fd, wildcard_match}; use crate::parse_util::parse_util_unescape_wildcards; use crate::wchar::{widestrs, wstr, WString}; +use crate::wchar_ext::WExt; use crate::wchar_ffi::WCharToFFI; use std::io::Write; use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd}; @@ -231,11 +232,11 @@ pub fn activate_flog_categories_by_pattern(wc_ptr: &wstr) { *c = '-'; } } - for s in wc.as_char_slice().split(|c| *c == ',') { - if s.starts_with(&['-']) { - apply_one_wildcard(wstr::from_char_slice(&s[1..]), false); + for s in wc.split(',') { + if s.starts_with('-') { + apply_one_wildcard(s.slice_from(1), false); } else { - apply_one_wildcard(wstr::from_char_slice(s), true); + apply_one_wildcard(s, true); } } } diff --git a/fish-rust/src/wutil/mod.rs b/fish-rust/src/wutil/mod.rs index 3c6a93f45..752022f43 100644 --- a/fish-rust/src/wutil/mod.rs +++ b/fish-rust/src/wutil/mod.rs @@ -12,6 +12,7 @@ use crate::fds::AutoCloseFd; use crate::flog::FLOGF; use crate::wchar::{wstr, WString, L}; +use crate::wchar_ext::WExt; use crate::wcstringutil::{join_strings, split_string, wcs2string_callback}; pub(crate) use gettext::{wgettext, wgettext_fmt}; use libc::{ @@ -202,11 +203,7 @@ pub fn normalize_path(path: &wstr, allow_leading_double_slashes: bool) -> WStrin leading_slashes += 1; } - let comps = path - .as_char_slice() - .split(|&c| c == sep) - .map(wstr::from_char_slice) - .collect::>(); + let comps: Vec<&wstr> = path.split(sep).collect(); let mut new_comps = Vec::new(); for comp in comps { if comp.is_empty() || comp == "." {