INNER CODE UNIT · Rust
fmt
c3rb3ru5d3d53c/binlex · crates/libvex/libvex-rs/src/lib.rs:260
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::AlreadyAllocated => "Some VEX objects are already allocated".fmt(f),
}
}
}
impl std::error::Error for LockError {}
impl LiftLock {
fn new() -> Self {
Self(ReentrantMutex::new(RefCell::new(0)))
}
fn exclusive_lock(&self) -> Result<LiftGuard<'_>, LockError> {
let guard = self.0.lock();
if *guard.borrow() != 0 {
return Err(LockError::AlreadyAllocated);