Skip to main content

PythonExt

Trait PythonExt 

Source
pub trait PythonExt {
    // Required method
    fn escape_for_python(&self) -> String;
}

Required Methods§

Source

fn escape_for_python(&self) -> String

Render a Path as a Python expression that evaluates to a str.

On Unix, paths are arbitrary byte strings, so this uses os.fsdecode() to produce a surrogate-escaped str. On Windows, paths are encoded as UTF-16, so this returns a str literal that preserves the original UTF-16 code units.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: AsRef<Path>> PythonExt for T