2 releases

0.0.1 Apr 22, 2020
0.0.0 Apr 22, 2020

#35 in #resolve

Download history 3482/week @ 2023-12-01 3332/week @ 2023-12-08 3055/week @ 2023-12-15 2072/week @ 2023-12-22 2058/week @ 2023-12-29 2694/week @ 2024-01-05 2923/week @ 2024-01-12 2478/week @ 2024-01-19 2363/week @ 2024-01-26 2433/week @ 2024-02-02 3403/week @ 2024-02-09 3204/week @ 2024-02-16 2761/week @ 2024-02-23 3170/week @ 2024-03-01 4061/week @ 2024-03-08 2893/week @ 2024-03-15

13,282 downloads per month
Used in 12 crates (8 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