Skip to main content

Escape

Trait Escape 

Source
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§

Source

fn source_len(&self) -> usize

Source

fn layout(&self) -> &EscapeLayout

Source

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.

Source

fn write_body_slow(&self, formatter: &mut impl Write) -> Result

Provided Methods§

Source

fn changed(&self) -> bool

Source

fn write_body(&self, formatter: &mut impl Write) -> Result

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.

Implementors§