#![cfg_attr(not(test), no_std)] #![feature(negative_impls)] #![cfg_attr(test, feature(box_vec_non_null))] mod raw_node; extern crate alloc; pub use raw_node::{ Color, Drain, Handle, LeftOrRight, RBTree, SearchResult, Side, TreeIter, TreeNodeIter, UnsafeNode, }; fn replace(v: &mut T, f: impl FnOnce(T) -> (T, R)) -> R { struct Guard; impl Drop for Guard { fn drop(&mut self) { panic!("replace() panicked"); } } let guard = Guard; let value = unsafe { core::ptr::read(v) }; let (new_value, ret) = f(value); unsafe { core::ptr::write(v, new_value) }; core::mem::forget(guard); ret }