Display in std::ffi::os_str - Rust (original) (raw)

Struct Display

1.87.0 · Source

pub struct Display<'a> { /* private fields */ }

Expand description

Helper struct for safely printing an OsStr with format! and {}.

An OsStr might contain non-Unicode data. This struct implements theDisplay trait in a way that mitigates that. It is created by thedisplay method on OsStr. This may perform lossy conversion, depending on the platform. If you would like an implementation which escapes the OsStr please use Debug instead.

§Examples

use std::ffi::OsStr;

let s = OsStr::new("Hello, world!");
println!("{}", s.display());

§

§

§

§

§

§