Function make_mut_storage
pub fn make_mut_storage(arc: &mut Arc<Storage>) -> &mut StorageExpand description
Helper to get a mutable reference to storage, cloning if needed (COW).
Uses Arc::make_mut semantics: if the Arc has only one strong reference,
returns a mutable reference to the existing allocation. Otherwise clones
the inner value first.
ยงExamples
use std::sync::Arc;
use tensor4all_tensorbackend::{make_mut_storage, Storage};
let s = Storage::from_dense_col_major(vec![1.0_f64, 2.0], &[2]).unwrap();
let mut arc = Arc::new(s);
let s_mut = make_mut_storage(&mut arc);
// s_mut is now a mutable reference to Storage
assert!(s_mut.is_f64());