Adopt the wchar prelude

This commit is contained in:
Henrik Hørlück Berg
2023-08-09 00:16:04 +02:00
committed by Johannes Altmanninger
parent 5d58652394
commit fae090ea67
42 changed files with 64 additions and 128 deletions

View File

@@ -4,7 +4,7 @@
sync::{Mutex, MutexGuard},
};
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::{AsWstr, WCharFromFFI, WCharToFFI};
use cxx::CxxWString;
use once_cell::sync::Lazy;
@@ -433,11 +433,8 @@ fn erase(&mut self, name: &CxxWString) {
}
use crate::ffi_tests::add_test;
add_test!("rename_abbrs", || {
use crate::wchar::wstr;
use crate::{
abbrs::{Abbreviation, Position},
wchar::L,
};
use crate::abbrs::{Abbreviation, Position};
use crate::wchar::prelude::*;
with_abbrs_mut(|abbrs_g| {
let mut add = |name: &wstr, repl: &wstr, position: Position| {

View File

@@ -21,15 +21,11 @@
variable_assignment_equals_pos, TokFlags, TokenType, Tokenizer, TokenizerError,
TOK_ACCEPT_UNFINISHED, TOK_CONTINUE_AFTER_ERROR, TOK_SHOW_COMMENTS,
};
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use crate::wchar_ffi::{wcharz, wcharz_t, AsWstr, WCharToFFI};
use crate::wutil::printf::sprintf;
use crate::wutil::wgettext_fmt;
use cxx::{type_id, ExternType};
use cxx::{CxxWString, UniquePtr};
use std::ops::{ControlFlow, Index, IndexMut};
use widestring_suffix::widestrs;
/**
* A NodeVisitor is something which can visit an AST node.

View File

@@ -1,13 +1,10 @@
use libc::c_int;
use widestring_suffix::widestrs;
use super::shared::{
builtin_print_help, io_streams_t, HelpOnlyCmdOpts, STATUS_CMD_OK, STATUS_INVALID_ARGS,
};
use crate::event;
use crate::ffi::parser_t;
use crate::wchar::{wstr, WString};
use crate::wutil::printf::sprintf;
use crate::wchar::prelude::*;
use libc::c_int;
#[widestrs]
pub fn emit(

View File

@@ -1,6 +1,5 @@
use libc::c_int;
use std::borrow::Cow;
use widestring_suffix::widestrs;
use super::shared::{
builtin_missing_argument, builtin_print_help, io_streams_t, BUILTIN_ERR_COMBO2,
@@ -9,9 +8,9 @@
use crate::common::{read_blocked, str2wcstring};
use crate::ffi::parser_t;
use crate::tinyexpr::te_interp;
use crate::wchar::{wstr, WString};
use crate::wchar::prelude::*;
use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t};
use crate::wutil::{fish_wcstoi, perror, sprintf, wgettext_fmt};
use crate::wutil::{fish_wcstoi, perror};
/// The maximum number of points after the decimal that we'll print.
const DEFAULT_SCALE: usize = 6;

View File

@@ -6,15 +6,14 @@
use crate::common;
use crate::ffi::parser_t;
use crate::ffi::Repin;
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::AsWstr;
mod test_expressions {
use super::{io_streams_t, wstr, WString, L};
use crate::wchar_ext::WExt;
use super::*;
use crate::wutil::{
file_id_for_path, fish_wcstol, fish_wcswidth, lwstat, sprintf, waccess, wcstod::wcstod,
wcstoi_opts, wgettext, wgettext_fmt, wstat, Error, Options,
file_id_for_path, fish_wcstol, fish_wcswidth, lwstat, waccess, wcstod::wcstod, wcstoi_opts,
wstat, Error, Options,
};
use once_cell::sync::Lazy;
use std::collections::HashMap;

View File

@@ -2,8 +2,7 @@
use crate::builtins::test::test as builtin_test;
use crate::ffi::{make_null_io_streams_ffi, parser_t};
use crate::wchar::{widestrs, WString, L};
use crate::wchar_ext::ToWString;
use crate::wchar::prelude::*;
fn run_one_test_test_mbracket(expected: i32, lst: &[&str], bracket: bool) -> bool {
let parser: &mut parser_t = unsafe { &mut *parser_t::principal_parser_ffi() };

View File

@@ -11,11 +11,10 @@
use crate::ffi::{builtin_exists, colorize_shell};
use crate::function;
use crate::path::{path_get_path, path_get_paths};
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharFromFFI;
use crate::wchar_ffi::WCharToFFI;
use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t};
use crate::wutil::{sprintf, wgettext, wgettext_fmt};
#[derive(Default)]
struct type_cmd_opts_t {

View File

@@ -1,9 +1,6 @@
use std::cmp::Ordering;
use crate::{
wchar::{widestrs, wstr, WExt, WString, L},
wutil::sprintf,
};
use crate::wchar::prelude::*;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Color24 {
@@ -487,10 +484,8 @@ pub fn from_ffi(&self) -> RgbColor {
#[cfg(test)]
mod tests {
use crate::{
color::{Color24, Flags, RgbColor, Type},
wchar::widestrs,
};
use crate::color::{Color24, Flags, RgbColor, Type};
use crate::wchar::prelude::*;
#[test]
#[widestrs]

View File

@@ -10,13 +10,12 @@
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::global_safety::RelaxedAtomicBool;
use crate::termsize::Termsize;
use crate::wchar::{decode_byte_from_char, encode_byte_to_char, wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::{decode_byte_from_char, encode_byte_to_char, prelude::*};
use crate::wchar_ffi::WCharToFFI;
use crate::wcstringutil::wcs2string_callback;
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::encoding::{mbrtowc, wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX};
use crate::wutil::{fish_iswalnum, sprintf, wgettext, wwrite_to_fd};
use crate::wutil::{fish_iswalnum, wwrite_to_fd};
use bitflags::bitflags;
use core::slice;
use cxx::{CxxWString, UniquePtr};
@@ -34,8 +33,6 @@
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
use std::sync::{Arc, Mutex, TryLockError};
use std::time;
use widestring::Utf32String;
use widestring_suffix::widestrs;
// Highest legal ASCII value.
pub const ASCII_MAX: char = 127 as char;
@@ -2063,10 +2060,10 @@ fn to_cstring(self) -> CString {
}
}
/// Safely converts from `&Utf32String` to a nul-terminated `CString` that can be passed to OS
/// Safely converts from `&WString` to a nul-terminated `CString` that can be passed to OS
/// functions, taking into account non-Unicode values that have been shifted into the private-use
/// range by using [`wcs2zstring()`].
impl ToCString for &Utf32String {
impl ToCString for &WString {
fn to_cstring(self) -> CString {
self.as_utfstr().to_cstring()
}

View File

@@ -8,10 +8,9 @@
use crate::global_safety::RelaxedAtomicBool;
use crate::null_terminated_array::OwningNullTerminatedArray;
use crate::threads::{is_forked_child, is_main_thread};
use crate::wchar::{widestrs, wstr, WExt, WString, L};
use crate::wchar_ext::ToWString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::{WCharFromFFI, WCharToFFI};
use crate::wutil::{fish_wcstol_radix, sprintf};
use crate::wutil::fish_wcstol_radix;
use autocxx::WithinUniquePtr;
use cxx::UniquePtr;

View File

@@ -6,11 +6,8 @@
use crate::flog::FLOGF;
use crate::function;
use crate::output::ColorSupport;
use crate::wchar::L;
use crate::wchar::{wstr, WString};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use crate::wutil::fish_wcstoi;
use crate::wutil::wgettext;
use std::borrow::Cow;
use std::collections::HashMap;
use std::ffi::{CStr, CString};

View File

@@ -11,7 +11,6 @@
use std::pin::Pin;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::{Arc, Mutex};
use widestring_suffix::widestrs;
use crate::builtins::shared::io_streams_t;
use crate::common::{escape_string, scoped_push, EscapeFlags, EscapeStringStyle, ScopeGuard};
@@ -20,10 +19,8 @@
use crate::job_group::{JobId, MaybeJobId};
use crate::signal::{signal_check_cancel, signal_handle, Signal};
use crate::termsize;
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::ToWString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::{wcharz_t, AsWstr, WCharFromFFI, WCharToFFI};
use crate::wutil::sprintf;
#[cxx::bridge]
mod event_ffi {

View File

@@ -2,9 +2,8 @@
use crate::env::Environment;
use crate::operation_context::OperationContext;
use crate::parse_constants::ParseErrorList;
use crate::wchar::{wstr, WString};
use crate::wchar::prelude::*;
use bitflags::bitflags;
use widestring_suffix::widestrs;
bitflags! {
/// Set of flags controlling expansions.

View File

@@ -4,7 +4,7 @@
//! Many of these functions are more or less broken and incomplete.
use crate::widecharwidth::{WcLookupTable, WcWidth};
use crate::{common::is_console_session, wchar::wstr};
use crate::{common::is_console_session, wchar::prelude::*};
use once_cell::sync::Lazy;
use std::cmp;
use std::sync::atomic::{AtomicI32, Ordering};
@@ -167,7 +167,6 @@ pub fn from(w: &'a wstr) -> Self {
#[test]
fn test_wcscasecmp() {
use crate::wchar::L;
use std::cmp::Ordering;
// Comparison with empty

View File

@@ -1,6 +1,6 @@
use crate::common::wcs2zstring;
use crate::ffi;
use crate::wchar::{wstr, L};
use crate::wchar::prelude::*;
use crate::wutil::perror;
use libc::EINTR;
use libc::{fcntl, F_GETFL, F_SETFL, O_CLOEXEC, O_NONBLOCK};

View File

@@ -1,4 +1,3 @@
use crate::wchar;
use crate::wchar_ffi::WCharToFFI;
#[rustfmt::skip]
use ::std::pin::Pin;
@@ -8,7 +7,7 @@
pub use crate::wait_handle::{
WaitHandleRef, WaitHandleRefFFI, WaitHandleStore, WaitHandleStoreFFI,
};
use crate::wchar::{wstr, WString};
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharFromFFI;
use autocxx::prelude::*;
use cxx::SharedPtr;
@@ -298,19 +297,19 @@ pub fn make_wait_handle(&mut self, jid: u64) -> Option<WaitHandleRef> {
}
/// Allow wcharz_t to be "into" wstr.
impl From<wcharz_t> for &wchar::wstr {
impl From<wcharz_t> for &wstr {
fn from(w: wcharz_t) -> Self {
let len = w.length();
#[allow(clippy::unnecessary_cast)]
let v = unsafe { slice::from_raw_parts(w.str_ as *const u32, len) };
wchar::wstr::from_slice(v).expect("Invalid UTF-32")
wstr::from_slice(v).expect("Invalid UTF-32")
}
}
/// Allow wcharz_t to be "into" WString.
impl From<wcharz_t> for wchar::WString {
impl From<wcharz_t> for WString {
fn from(w: wcharz_t) -> Self {
let w: &wchar::wstr = w.into();
let w: &wstr = w.into();
w.to_owned()
}
}

View File

@@ -1,7 +1,6 @@
use crate::ffi::wildcard_match;
use crate::parse_util::parse_util_unescape_wildcards;
use crate::wchar::{widestrs, wstr, WString};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI;
use libc::c_int;
use std::io::Write;

View File

@@ -10,8 +10,7 @@
use crate::global_safety::RelaxedAtomicBool;
use crate::parse_tree::{NodeRef, ParsedSourceRefFFI};
use crate::parser_keywords::parser_keywords_is_reserved;
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use crate::wchar_ffi::wcstring_list_ffi_t;
use crate::wchar_ffi::{AsWstr, WCharFromFFI, WCharToFFI};
use crate::wutil::{dir_iter::DirIter, gettext::wgettext_expr, sprintf};

View File

@@ -1,10 +1,9 @@
//! Flags to enable upcoming features
use crate::ffi::wcharz_t;
use crate::wchar::wstr;
use crate::wchar::prelude::*;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use widestring_suffix::widestrs;
#[cxx::bridge]
mod future_feature_flags_ffi {

View File

@@ -13,14 +13,13 @@
use crate::redirection::{RedirectionMode, RedirectionSpecList};
use crate::signal::SigChecker;
use crate::topic_monitor::topic_t;
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wutil::{perror, perror_io, wdirname, wstat, wwrite_to_fd};
use errno::Errno;
use libc::{EAGAIN, EEXIST, EINTR, ENOENT, ENOTDIR, EPIPE, EWOULDBLOCK, O_EXCL, STDERR_FILENO};
use std::cell::UnsafeCell;
use std::sync::{Arc, Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard};
use std::{os::fd::RawFd, rc::Rc};
use widestring_suffix::widestrs;
/// separated_buffer_t represents a buffer of output from commands, prepared to be turned into a
/// variable. For example, command substitutions output into one of these. Most commands just

View File

@@ -1,8 +1,7 @@
use self::ffi::pgid_t;
use crate::common::{assert_send, assert_sync};
use crate::signal::Signal;
use crate::wchar::WString;
use crate::wchar_ext::ToWString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::{WCharFromFFI, WCharToFFI};
use cxx::{CxxWString, UniquePtr};
use std::num::NonZeroU32;

View File

@@ -9,7 +9,7 @@
use std::sync::Mutex;
use crate::ffi::wcstring_list_ffi_t;
use crate::wchar::WString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharFromFFI;
#[cxx::bridge]

View File

@@ -3,8 +3,7 @@
use crate::common::{self, assert_is_locked, wcs2string_appending};
use crate::curses::{self, tparm1, Term};
use crate::env::EnvVar;
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use bitflags::bitflags;
use std::cell::RefCell;
use std::ffi::{CStr, CString};

View File

@@ -2,13 +2,11 @@
use crate::ffi::{fish_wcswidth, fish_wcwidth, wcharz_t};
use crate::tokenizer::variable_assignment_equals_pos;
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::{wcharz, AsWstr, WCharFromFFI, WCharToFFI};
use crate::wutil::{sprintf, wgettext_fmt};
use bitflags::bitflags;
use cxx::{type_id, ExternType};
use cxx::{CxxWString, UniquePtr};
use widestring_suffix::widestrs;
pub type SourceOffset = u32;

View File

@@ -11,9 +11,8 @@
ParseKeyword, ParseTokenType, ParseTreeFlags, SourceOffset, SourceRange, SOURCE_OFFSET_INVALID,
};
use crate::tokenizer::TokenizerError;
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::{WCharFromFFI, WCharToFFI};
use crate::wutil::sprintf;
use cxx::{CxxWString, UniquePtr};
/// A struct representing the token type that we use internally.

View File

@@ -24,15 +24,12 @@
comment_end, is_token_delimiter, quote_end, Tok, TokenType, Tokenizer, TOK_ACCEPT_UNFINISHED,
TOK_SHOW_COMMENTS,
};
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use crate::wchar_ffi::{WCharFromFFI, WCharToFFI};
use crate::wcstringutil::truncate;
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::{wgettext, wgettext_fmt};
use cxx::CxxWString;
use std::ops;
use widestring_suffix::widestrs;
/// Handles slices: the square brackets in an expression like $foo[5..4]
/// \return the length of the slice starting at \p in, or 0 if there is no slice, or -1 on error.

View File

@@ -1,7 +1,6 @@
//! Functions having to do with parser keywords, like testing if a function is a block command.
use crate::wchar::wstr;
use widestring_suffix::widestrs;
use crate::wchar::prelude::*;
#[widestrs]
const SKIP_KEYWORDS: &[&wstr] = &["else"L, "begin"L];

View File

@@ -8,10 +8,8 @@
use crate::env::{EnvMode, EnvStack, Environment};
use crate::expand::{expand_tilde, HOME_DIRECTORY};
use crate::flog::{FLOG, FLOGF};
use crate::wchar::{wstr, WExt, WString, L};
use crate::wutil::{
normalize_path, path_normalize_for_cd, waccess, wdirname, wgettext, wgettext_fmt, wmkdir, wstat,
};
use crate::wchar::prelude::*;
use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wmkdir, wstat};
use errno::{errno, set_errno, Errno};
use libc::{EACCES, ENOENT, ENOTDIR, F_OK, X_OK};
use once_cell::sync::Lazy;
@@ -19,7 +17,6 @@
use std::io::{ErrorKind, Write};
use std::os::unix::ffi::OsStrExt;
use std::os::unix::prelude::MetadataExt;
use widestring_suffix::widestrs;
/// Returns the user configuration directory for fish. If the directory or one of its parents
/// doesn't exist, they are first created.

View File

@@ -1,4 +1,4 @@
use crate::wchar::{wstr, WString, L};
use crate::wchar::prelude::*;
/// Adjust a pattern so that it is anchored at both beginning and end.
/// This is a workaround for the fact that PCRE2_ENDANCHORED is unavailable on pre-2017 PCRE2

View File

@@ -1,7 +1,7 @@
//! This file supports specifying and applying redirections.
use crate::ffi::wcharz_t;
use crate::wchar::{WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI;
use crate::wutil::fish_wcstoi;
use cxx::{CxxVector, CxxWString, SharedPtr, UniquePtr};

View File

@@ -4,13 +4,12 @@
use crate::event::{enqueue_signal, is_signal_observed};
use crate::termsize::termsize_handle_winch;
use crate::topic_monitor::{generation_t, invalid_generations, topic_monitor_principal, topic_t};
use crate::wchar::{wstr, WExt, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::{AsWstr, WCharToFFI};
use crate::wutil::{fish_wcstoi, perror, wgettext, wgettext_str};
use crate::wutil::{fish_wcstoi, perror};
use cxx::{CxxWString, UniquePtr};
use errno::{errno, set_errno};
use std::sync::atomic::{AtomicI32, Ordering};
use widestring_suffix::widestrs;
#[cxx::bridge]
mod signal_ffi {
@@ -593,7 +592,6 @@ fn from(value: Signal) -> Self {
#[rustfmt::skip]
add_test!("test_signal_parse", || {
use crate::wchar_ext::ToWString;
assert_eq!(Signal::parse(L!("SIGHUP")), Some(Signal::new(libc::SIGHUP)));
assert_eq!(Signal::parse(L!("sigwinch")), Some(Signal::new(libc::SIGWINCH)));
assert_eq!(Signal::parse(L!("TSTP")), Some(Signal::new(libc::SIGTSTP)));

View File

@@ -3,8 +3,7 @@
use crate::env::{EnvMode, EnvStackRefFFI, EnvVar, Environment};
use crate::ffi::{parser_t, Repin};
use crate::flog::FLOG;
use crate::wchar::{WString, L};
use crate::wchar_ext::ToWString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI;
use crate::wutil::fish_wcstoi;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};

View File

@@ -33,10 +33,8 @@
ops::{BitAnd, BitOr, BitXor},
};
use widestring_suffix::widestrs;
use crate::{
wchar::wstr,
wchar::prelude::*,
wutil::{wcstod::wcstod_underscores, wgettext},
};

View File

@@ -6,14 +6,12 @@
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::parse_constants::SOURCE_OFFSET_INVALID;
use crate::redirection::RedirectionMode;
use crate::wchar::{wstr, WExt, WString, L};
use crate::wchar::prelude::*;
use crate::wchar_ffi::{wchar_t, AsWstr, WCharToFFI};
use crate::wutil::wgettext;
use cxx::{CxxWString, SharedPtr, UniquePtr};
use libc::{c_int, STDIN_FILENO, STDOUT_FILENO};
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not};
use std::os::fd::RawFd;
use widestring_suffix::widestrs;
#[cxx::bridge]
mod tokenizer_ffi {

View File

@@ -2,7 +2,7 @@
common::escape,
ffi::{self, parser_t, wcharz_t, wcstring_list_ffi_t},
global_safety::RelaxedAtomicBool,
wchar::{self, wstr, L},
wchar::prelude::*,
wchar_ffi::{WCharFromFFI, WCharToFFI},
};
@@ -43,9 +43,9 @@ pub fn trace_enabled(parser: &parser_t) -> bool {
// Allow the `&Vec` parameter as this function only exists temporarily for the FFI
#[allow(clippy::ptr_arg)]
fn trace_argv_ffi(parser: &parser_t, command: wcharz_t, args: &wcstring_list_ffi_t) {
let command: wchar::WString = command.into();
let args: Vec<wchar::WString> = args.from_ffi();
let args_ref: Vec<&wstr> = args.iter().map(wchar::WString::as_utfstr).collect();
let command: WString = command.into();
let args: Vec<WString> = args.from_ffi();
let args_ref: Vec<&wstr> = args.iter().map(WString::as_utfstr).collect();
trace_argv(parser, command.as_utfstr(), &args_ref);
}

View File

@@ -1,7 +1,7 @@
//! Generic utilities library.
use crate::ffi::wcharz_t;
use crate::wchar::wstr;
use crate::wchar::prelude::*;
use std::cmp::Ordering;
use std::time;
@@ -261,8 +261,6 @@ fn wcsfilecmp_leading_digits(a: &wstr, b: &wstr) -> (Ordering, usize, usize) {
/// Verify the behavior of the `wcsfilecmp()` function.
#[test]
fn test_wcsfilecmp() {
use crate::wchar::L;
macro_rules! validate {
($str1:expr, $str2:expr, $expected_rc:expr) => {
assert_eq!(wcsfilecmp(L!($str1), L!($str2)), $expected_rc)

View File

@@ -1,4 +1,4 @@
use crate::wchar::WString;
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharFromFFI;
use cxx::CxxWString;
use libc::pid_t;
@@ -243,8 +243,6 @@ pub fn size(&self) -> usize {
#[test]
fn test_wait_handles() {
use crate::wchar::L;
let limit: usize = 4;
let mut whs = WaitHandleStore::new_with_capacity(limit);
assert_eq!(whs.size(), 0);

View File

@@ -274,8 +274,8 @@ fn as_char_slice(&self) -> &[char] {
#[cfg(test)]
mod tests {
use super::WExt;
use crate::wchar::{wstr, WString, L};
use super::*;
use crate::wchar::L;
/// Write some tests.
#[cfg(test)]
fn test_find_char() {

View File

@@ -5,8 +5,7 @@
use crate::expand::INTERNAL_SEPARATOR;
use crate::fallback::{fish_wcwidth, wcscasecmp};
use crate::flog::FLOGF;
use crate::wchar::{decode_byte_from_char, wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wchar::{decode_byte_from_char, prelude::*};
use crate::wutil::encoding::{wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX};
/// Test if a string prefixes another without regard to case. Returns true if a is a prefix of b.
@@ -604,7 +603,6 @@ macro_rules! validate {
#[test]
fn test_join_strings() {
use crate::wchar::L;
let empty: &[&wstr] = &[];
assert_eq!(join_strings(empty, '/'), "");
assert_eq!(join_strings(&[] as &[&wstr], '/'), "");

View File

@@ -23,7 +23,7 @@
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
use crate::wchar::{wstr, WExt, L};
use crate::wchar::prelude::*;
/// Describe how to deal with options that follow non-option ARGV-elements.
///

View File

@@ -1,5 +1,4 @@
use super::*;
use widestring_suffix::widestrs;
#[test]
#[widestrs]

View File

@@ -1,6 +1,5 @@
pub use super::errors::Error;
use crate::wchar::{wstr, IntoCharIter};
use crate::wchar_ext::WExt;
use crate::wchar::prelude::*;
use num_traits::{NumCast, PrimInt};
use std::default::Default;
use std::iter::{Fuse, Peekable};
@@ -326,7 +325,6 @@ pub fn fish_wcstoul(mut src: &wstr) -> Result<u64, Error> {
#[cfg(test)]
mod tests {
use super::*;
use crate::wchar::L;
fn test_min_max<Int: PrimInt + std::fmt::Display + std::fmt::Debug>(min: Int, max: Int) {
assert_eq!(wcstoi(min.to_string().chars()), Ok(min));