diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index 7e4730a973f4995c4c33aa25ccfad6199ceefc23..02501cd4f1ce247d52426c6879306d4eb995a1a5 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -214,17 +214,26 @@ pub fn would_block(err: &std::io::Error) -> bool { err.kind() == std::io::ErrorKind::WouldBlock } impl VecSet { - fn iter(&self) -> std::slice::Iter { - self.vec.iter() - } - fn contains(&self, element: &T) -> bool { - self.vec.binary_search(element).is_ok() - } fn new(mut vec: Vec) -> Self { vec.sort(); vec.dedup(); Self { vec } } + fn contains(&self, element: &T) -> bool { + self.vec.binary_search(element).is_ok() + } + fn insert(&mut self, element: T) -> bool { + match self.vec.binary_search(&element) { + Ok(_) => false, + Err(index) => { + self.vec.insert(index, element); + true + } + } + } + fn iter(&self) -> std::slice::Iter { + self.vec.iter() + } } impl PortInfo { fn firing_var_for(&self, port: PortId) -> FiringVar {