Skip to main content

Take

Trait Take 

Source
pub trait Take: Layout {
    // Required method
    fn take(&mut self) -> Self;
}
Expand description

A layout that can be emptied.

This trait contains all layout types from which we can steal their memory buffer. This is incredibly useful for fallible operations that change the type of a buffers layout. Instead of being required to take the buffer by value and return the original in case of an error they can use the much natural signature:

  • fn mutate(&mut self) -> Result<Converted, Err>

where semantics are that the buffer is unchanged in case of error but has been moved to the type Converted in case of success. This is very similar to the method Vec::take and others.

It is expected that the byte_len is 0 after the operation.

This trait is not simply a clone of Default. While we expect that the described image contains no bytes after the operation other data such as channel count, color space information, image plane order, alpha interpretation should be retained.

Required Methods§

Source

fn take(&mut self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§