pub trait Quotable {
    fn quote(&self) -> Quoted<'_>;

    fn maybe_quote(&self) -> Quoted<'_> { ... }
}
Expand description

An extension trait to apply quoting to strings.

This is implemented on str, OsStr and Path.

For finer control, see the constructors on Quoted.

Required Methods

Returns an object that implements Display for printing strings with proper quoting and escaping for the platform.

On Unix this corresponds to bash/ksh syntax, on Windows PowerShell syntax is used.

Examples
use std::path::Path;
use os_display::Quotable;

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

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

Provided Methods

Like quote(), but don’t actually add quotes unless necessary because of whitespace or special characters.

Examples
use std::path::Path;
use os_display::Quotable;

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

println!("{}: Not found", foo.maybe_quote()); // Prints "foo/bar.baz: Not found"
println!("{}: Not found", bar.maybe_quote()); // Prints "'foo bar': Not found"

Implementations on Foreign Types

Implementors