[][src]Trait osstrtools::OsStringTools

pub trait OsStringTools {
    fn replace(self, pat: impl Bytes, to: impl Bytes) -> OsString;
fn escape_double_quote(self) -> OsString;
fn escape_single_quote(self) -> OsString;
fn trim_start(self, pat: impl Bytes) -> OsString;
fn trim_end(self, pat: impl Bytes) -> OsString; }

Includes some of the methods of OsStrTools but they take the OsString by value and return it without modification if the specific search pattern isn't found.

Allocation is also avoided by reusing parts of the old string when possible. As such, the methods here can be slightly faster and might be preferable in some cases.

Required methods

fn replace(self, pat: impl Bytes, to: impl Bytes) -> OsString

Replace all matches with something else.

If no matches are found the returned string contains the whole original string.

fn escape_double_quote(self) -> OsString

Replace double quote characters in the string with "\\\"" for safe handling over to a shell.

fn escape_single_quote(self) -> OsString

Replace single quote characters in the string with "\\''" for safe handling over to a shell.

fn trim_start(self, pat: impl Bytes) -> OsString

Remove all matches of the pattern until a different character is found.

Returns the rest.

fn trim_end(self, pat: impl Bytes) -> OsString

Remove all matches of the pattern from the end until a different character is found.

Returns the rest.

Loading content...

Implementations on Foreign Types

impl OsStringTools for OsString[src]

Loading content...

Implementors

Loading content...