Skip to main content

luaur_common/records/
item_interface_set.rs

1#[allow(non_snake_case)]
2#[derive(Debug, Clone, Copy)]
3pub struct ItemInterfaceSet;
4
5#[allow(non_snake_case)]
6impl ItemInterfaceSet {
7    #[inline]
8    pub fn getKey<Key>(item: &Key) -> &Key {
9        item
10    }
11
12    #[inline]
13    pub fn setKey<Key: Clone>(item: &mut Key, key: &Key) {
14        *item = key.clone();
15    }
16
17    #[inline]
18    pub fn fill<Key: Clone>(data: *mut Key, count: usize, key: &Key) {
19        for i in 0..count {
20            unsafe {
21                data.add(i).write(key.clone());
22            }
23        }
24    }
25
26    #[inline]
27    pub fn destroy<Key>(data: *mut Key, count: usize) {
28        for i in 0..count {
29            unsafe {
30                core::ptr::drop_in_place(data.add(i));
31            }
32        }
33    }
34}