packos 0.1.0

Simple rectangle packing library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{
    num::NonZeroUsize,
    sync::atomic::{AtomicUsize, Ordering},
};

static LAST_ID: AtomicUsize = AtomicUsize::new(1);

/// Represents an item tracked by Packos.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Id(NonZeroUsize);

impl Id {
    pub(crate) fn new() -> Self {
        let id = LAST_ID.fetch_add(1, Ordering::SeqCst);
        Id(NonZeroUsize::new(id).unwrap())
    }
}