[−][src]Struct crunch::Packer
A packer for items of type Item<T>.
Implementations
impl<T> Packer<T>[src]
pub fn new() -> Self[src]
Create a new, empty packer.
pub fn with_capacity(capacity: usize) -> Self[src]
Create a packer with an initial capacity to prevent collection resizing.
pub fn with_items<I: IntoIterator<Item = Item<T>>>(items: I) -> Self[src]
Create a packer initialized with the collection of items.
impl<T: Clone> Packer<T>[src]
pub fn clear(&mut self) -> &mut Self[src]
pub fn push(&mut self, item: Item<T>) -> &mut Self[src]
pub fn extend<I: IntoIterator<Item = Item<T>>>(&mut self, items: I) -> &mut Self[src]
pub fn pack(
&mut self,
into_rect: Rect
) -> Result<PackedItems<T>, PackedItems<T>>[src]
&mut self,
into_rect: Rect
) -> Result<PackedItems<T>, PackedItems<T>>
Attempt to pack all the items into into_rect. The returned PackedItems
will contain positions for all packed items on success, or just the items
the packer was able to successfull pack before failing.
This function uses some internal intermediary collections, which is why
it is mutable, so it cannot be called but it is valid to call it multiple times with different
into_rect values.
If you want to attempt to pack the same item list into several different
into_rect, it is valid to call this function multiple times on the same
Packer, and it will re-use its intermediary data structures.
pub fn pack_into_po2(
&mut self,
max_size: usize
) -> Result<(usize, usize, PackedItems<T>), ()>[src]
&mut self,
max_size: usize
) -> Result<(usize, usize, PackedItems<T>), ()>
Attempts to pack the supplied items into the smallest power of 2 container
it possibly can while not exceeding the provided max_size.
On success, returns the size of the container (a power of 2) and the packed items.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Packer<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Packer<T> where
T: Send,
T: Send,
impl<T> Sync for Packer<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Packer<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Packer<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,