pub unsafe trait Escape {
// Required methods
fn source_len(&self) -> usize;
fn layout(&self) -> &EscapeLayout;
unsafe fn write_source(&self, formatter: &mut impl Write) -> Result;
fn write_body_slow(&self, formatter: &mut impl Write) -> Result;
// Provided methods
fn changed(&self) -> bool { ... }
fn write_body(&self, formatter: &mut impl Write) -> Result { ... }
}Expand description
Represents string types that can be escape-printed.
§Safety
source_len and layout must be accurate, and layout.len must not be equal
to Some(source_len) if the string contains non-printable characters.
Required Methods§
fn source_len(&self) -> usize
fn layout(&self) -> &EscapeLayout
Sourceunsafe fn write_source(&self, formatter: &mut impl Write) -> Result
unsafe fn write_source(&self, formatter: &mut impl Write) -> Result
Write the body of the string directly to the formatter.
§Safety
This string must only contain printable characters.
fn write_body_slow(&self, formatter: &mut impl Write) -> Result
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.