pub fn with_device<F, T, E>(
device: Option<Rc<RefCell<Device>>>,
f: F,
) -> Result<T, E>Expand description
Executes a closure with a mutable reference to a Device.
This helper function centralizes the boilerplate for safely acquiring a
mutable borrow of a Device from the shared Rc<RefCell<...>>.
§Errors
Returns an error if the device is not available or is already borrowed. The
error is converted into the caller’s error type E.