2 releases

0.0.1 Apr 22, 2020
0.0.0 Apr 22, 2020

#91 in #clean

Download history 5143/week @ 2024-07-25 4651/week @ 2024-08-01 3986/week @ 2024-08-08 3166/week @ 2024-08-15 4304/week @ 2024-08-22 3908/week @ 2024-08-29 4175/week @ 2024-09-05 3986/week @ 2024-09-12 4242/week @ 2024-09-19 4652/week @ 2024-09-26 5705/week @ 2024-10-03 4317/week @ 2024-10-10 5035/week @ 2024-10-17 4090/week @ 2024-10-24 5599/week @ 2024-10-31 6064/week @ 2024-11-07

21,673 downloads per month
Used in 16 crates (9 directly)

CC0 license

6KB
60 lines

lexiclean

Lexically clean rust paths.

See the docs for more information.


lib.rs:

This crate exports a single trait, Lexiclean, with a single method, lexiclean, implemented on &Path, that performs lexical path cleaning.

Lexical path cleaning simplifies paths without looking at the underlying filesystem. This means:

  • Normally, if file is a file and not a directory, the path file/.. will fail to resolve to. Lexiclean resolves this to .

  • Path::canonicalize returns io::Result<PathBuf>, because it must make system calls, that might fail. Lexiclean does not make system calls, and thus cannot fail.

  • The path returned by lexiclean will only contain components present in the input path. This can make the resultant paths more legible for users, since foo/.. will resolve to ., and not /Some/absolute/directory.

  • Lexiclean does not respect symlinks.

  • Lexiclean has only been lightly tested. In particular, it has not been tested with windows paths, which are very complicated, and can contain many types of components that the author of this crate never contemplated.

    Additional test cases and bug fixes are most welcome!

No runtime deps