Skip to main content

PainterExt

Trait PainterExt 

Source
pub trait PainterExt: Painter {
    // Provided method
    fn with_clip(&mut self, rect: Rect) -> Clipped<'_, Self> { ... }
}
Expand description

The part of the painting API that cannot be object-safe.

Blanket-implemented for every Painter, dyn Painter included, so it needs no thought at the call site beyond importing it.

Provided Methods§

Source

fn with_clip(&mut self, rect: Rect) -> Clipped<'_, Self>

A view of the same target with a tighter clip, restored on drop.

This is how a parent hands a child a region to draw in without either being able to escape it: the returned guard borrows the painter, so the parent cannot draw until it is dropped, and the child cannot widen the clip because it has no token to widen it with.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<P> PainterExt for P
where P: Painter + ?Sized,