pub struct PrinterPath<'a>(_);
Expand description

A simple encapsulation of a file path used by a printer.

This represents any transforms that we might want to perform on the path, such as converting it to valid UTF-8 and/or replacing its separator with something else. This allows us to amortize work if we are printing the file path for every match.

In the common case, no transformation is needed, which lets us avoid the allocation. Typically, only Windows requires a transform, since we can’t access the raw bytes of a path directly and first need to lossily convert to UTF-8. Windows is also typically where the path separator replacement is used, e.g., in cygwin environments to use / instead of \.

Users of this type are expected to construct it from a normal Path found in the standard library. It can then be written to any io::Write implementation using the as_bytes method. This achieves platform portability with a small cost: on Windows, paths that are not valid UTF-16 will not roundtrip correctly.

Implementations§

Create a new path suitable for printing.

Create a new printer path from the given path which can be efficiently written to a writer without allocation.

If the given separator is present, then any separators in path are replaced with it.

Return the raw bytes for this path.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.