pub trait IntoView {
type View;
// Required method
fn into_view(self) -> Self::View;
}Expand description
Trait for converting types to immutable views.
This trait provides a unified way to create efficient read-only views of various sparse matrix and vector types without allocation. Views are useful for:
- Passing data to functions without transferring ownership
- Creating temporary references for computation
- Implementing generic algorithms that work with multiple matrix types
§Examples
use algebra_sparse::{CsrMatrix, traits::IntoView};
use nalgebra::DMatrix;
let dense = DMatrix::from_row_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let csr = CsrMatrix::from_dense(dense.as_view());
// Create view for read-only operations
let view = csr.as_view(); // or csr.into_view()
println!("Shape: {:?}", view.shape());