MCPcopy Create free account
hub / github.com/PerroEngine/Perro / insert_slot

Function insert_slot

perro_source/api_modules/perro_networking/src/slot.rs:3–10  ·  view source on GitHub ↗
(slots: &mut Vec<Option<T>>, value: T)

Source from the content-addressed store, hash-verified

1use super::*;
2
3pub(crate) fn insert_slot<T>(slots: &mut Vec<Option<T>>, value: T) -> u32 {
4 if let Some(i) = slots.iter().position(Option::is_none) {
5 slots[i] = Some(value);
6 return i as u32;
7 }
8 slots.push(Some(value));
9 (slots.len() - 1) as u32
10}
11
12pub(crate) fn remove_slot<T>(slots: &mut [Option<T>], id: u32) -> bool {
13 let Some(slot) = slots.get_mut(id as usize) else {

Callers 9

bind_tcp_hostMethod · 0.85
connect_tcpMethod · 0.85
bind_udpMethod · 0.85
bind_websocket_hostMethod · 0.85
connect_websocketMethod · 0.85
poll_acceptsMethod · 0.85

Calls 4

positionMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected