#object-store #container #arceos

no-std flatten_objects

A container that stores numbered objects. Each object can be assigned with a unique ID.

6 releases

Uses new Rust 2024

0.2.4 Jun 30, 2025
0.2.3 Mar 7, 2025
0.2.1 Dec 17, 2024
0.1.0 Jul 11, 2024

#681 in Data structures

Download history 97/week @ 2025-10-02 395/week @ 2025-10-09 190/week @ 2025-10-16 333/week @ 2025-10-23 543/week @ 2025-10-30 455/week @ 2025-11-06 915/week @ 2025-11-13 638/week @ 2025-11-20 1022/week @ 2025-11-27 721/week @ 2025-12-04 898/week @ 2025-12-11 536/week @ 2025-12-18 283/week @ 2025-12-25 127/week @ 2026-01-01 294/week @ 2026-01-08 265/week @ 2026-01-15

981 downloads per month

GPL-3.0-or-later OR Apache-2…

16KB
131 lines

flatten_objects

Crates.io Docs.rs CI

FlattenObjects is a container that stores numbered objects.

Objects can be added to the FlattenObjects, a unique ID will be assigned to the object. The ID can be used to retrieve the object later.

Example

use flatten_objects::FlattenObjects;

let mut objects = FlattenObjects::<u32, 20>::new();

// Add `23` 10 times and assign them IDs from 0 to 9.
for i in 0..=9 {
    objects.add_at(i, 23).unwrap();
    assert!(objects.is_assigned(i));
}

// Remove the object with ID 6.
assert_eq!(objects.remove(6), Some(23));
assert!(!objects.is_assigned(6));

// Add `42` (the ID 6 is available now).
let id = objects.add(42).unwrap();
assert_eq!(id, 6);
assert!(objects.is_assigned(id));
assert_eq!(objects.get(id), Some(&42));
assert_eq!(objects.remove(id), Some(42));
assert!(!objects.is_assigned(id));

Dependencies

~72KB