Skip to main content

Module display

Module display 

Source
Expand description

Utilities for printing paths, with special attention paid to special characters and invalid unicode.

For displaying paths in informational messages use Quotable::quote. This will wrap quotes around the filename and add the necessary escapes to make it copy/paste-able into a shell.

For writing raw paths to stdout when the output should not be quoted or escaped, use println_verbatim. This will preserve invalid unicode.

§Examples

use std::path::Path;
use uucore::display::{Quotable, println_verbatim};

let path = Path::new("foo/bar.baz");

println!("Found file {}", path.quote()); // Prints "Found file 'foo/bar.baz'"
println_verbatim(path)?; // Prints "foo/bar.baz"

Structs§

Quoted
A wrapper around string types for displaying with quoting and escaping applied.

Traits§

OsWrite
io::Write, but for OS strings.
Quotable
An extension trait to apply quoting to strings.

Functions§

print_all_env_vars
Print all environment variables in the format name=value with the specified line ending.
print_verbatim
Like println_verbatim, without the trailing newline.
println_verbatim
Print a path (or OsStr-like object) directly to stdout, with a trailing newline, without losing any information if its encoding is invalid.