Skip to content

Commit 778365d

Browse files
committed
Use Box<OsStr> instead of OsString for filename storage
1 parent b7dbb48 commit 778365d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ doctest!("../README.md");
7272
use std::cmp;
7373
use std::cmp::Ordering;
7474
use std::error::Error;
75-
use std::ffi::OsString;
75+
use std::ffi::OsStr;
7676
use std::fmt;
7777
use std::fs;
7878
use std::fs::DirEntry;
@@ -330,11 +330,11 @@ impl fmt::Display for GlobError {
330330
struct PathWrapper {
331331
path: PathBuf,
332332
is_directory: bool,
333-
file_name: Option<OsString>,
333+
file_name: Option<Box<OsStr>>,
334334
}
335335

336336
impl PathWrapper {
337-
fn from_dir_entry(path: PathBuf, file_name: Option<OsString>, e: DirEntry) -> Self {
337+
fn from_dir_entry(path: PathBuf, file_name: Option<Box<OsStr>>, e: DirEntry) -> Self {
338338
let is_directory = e
339339
.file_type()
340340
.ok()
@@ -357,7 +357,7 @@ impl PathWrapper {
357357
}
358358
fn from_path(path: PathBuf) -> Self {
359359
let is_directory = fs::metadata(&path).map(|m| m.is_dir()).unwrap_or(false);
360-
let file_name = path.file_name().map(ToOwned::to_owned);
360+
let file_name = path.file_name().map(Box::from);
361361
Self {
362362
path,
363363
is_directory,
@@ -944,10 +944,10 @@ fn fill_todo(
944944
let (path, file_name) = if curdir {
945945
let path = e.path();
946946
let file_name = path.file_name().unwrap();
947-
(PathBuf::from(file_name), Some(file_name.to_owned()))
947+
(PathBuf::from(file_name), Some(Box::from(file_name)))
948948
} else {
949949
let path = e.path();
950-
let file_name = path.file_name().map(ToOwned::to_owned);
950+
let file_name = path.file_name().map(Box::from);
951951
(path, file_name)
952952
};
953953
PathWrapper::from_dir_entry(path, file_name, e)

0 commit comments

Comments
 (0)