Function std::is_writable

Overview
fn is_writable(value: any) -> bool

Test if the given value is writable.

A value is writable if can be acquired for exclusive access, such as producing a mutable reference or taking ownership.

Examples

let value = Some(42);
assert!(is_writable(value));
let value2 = value.map(|v| v + 1);
drop(value);
assert!(!is_writable(value));
assert_eq!(value2, Some(43));