Expand description
Expanding tildes in paths.
If the path starts with the ~ character, it will be expanded to the home directory.
Any presence of ~ in paths except for the first character will not be expanded.
The home directory is provided by the home_dir function.
§Example
There are two main ways to expand tildes with this crate;
the first is to use the expand_tilde function directly:
use expand_tilde::expand_tilde;
let path = "~/.config";
let expanded = expand_tilde(path).unwrap();
println!("{}", expanded.display()); // something like `/home/nekit/.config`And the other way is to use the sealed extension trait:
use expand_tilde::ExpandTilde;
let path = "~/.config";
let expanded = path.expand_tilde().unwrap();
println!("{}", expanded.display()); // something like `/home/nekit/.config`The latter method simply calls the former one under the hood.
Enums§
- Represents errors that can occur during
~expansion.
Constants§
- The
~literal.
Traits§
- Represents values that can be tilde-expanded (sealed extension trait).
Functions§
- Expands the tilde (
~) component to the home directory. - Expands the tilde (
~) component of thePathto the home directory. - Wraps
home::home_dirto improve diagnostics.
Type Aliases§
- The result type used by this crate.