From bd39ce754fa2c0a225d5634efa7943c527874f91 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 12 Jun 2022 19:23:03 +1000 Subject: [PATCH] Fix `Vfs::add_path`: Use `to_string_lossy` instead of `to_str` to be compatible with the implementation in `cargo_toml`: https://docs.rs/cargo_toml/0.11.5/src/cargo_toml/afs.rs.html#24 Signed-off-by: Jiahao XU --- src/drivers/vfs.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/drivers/vfs.rs b/src/drivers/vfs.rs index d43b3a8a..18c422de 100644 --- a/src/drivers/vfs.rs +++ b/src/drivers/vfs.rs @@ -20,12 +20,14 @@ impl Vfs { // Since path has parent, it must have a filename let filename = path.file_name().unwrap(); - if let Some(filename) = filename.to_str() { - self.0 - .entry(parent.into()) - .or_insert_with(|| HashSet::with_capacity(4)) - .insert(filename.into()); - } + // `cargo_toml`'s implementation does the same thing. + // https://docs.rs/cargo_toml/0.11.5/src/cargo_toml/afs.rs.html#24 + let filename = filename.to_string_lossy(); + + self.0 + .entry(parent.into()) + .or_insert_with(|| HashSet::with_capacity(4)) + .insert(filename.into()); path = parent; }