Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix docs link and format for CI
  • Loading branch information
at264939-ctrl committed Jun 19, 2026
commit da0b686cfb28323a7250d22df4387c8c03abc104
4 changes: 2 additions & 2 deletions src/impl_views/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ where D: Dimension
{
/// Convert into a read-only view.
///
/// Unlike [`Self::view`], this method consumes the mutable view and preserves
/// the original lifetime of the data.
/// This method consumes the mutable view and returns an `ArrayView` that
/// preserves the original lifetime `'a` of the data.
pub fn into_view(self) -> ArrayView<'a, A, D>
{
unsafe { ArrayView::new(self.parts.ptr, self.parts.dim, self.parts.strides) }
Expand Down
12 changes: 8 additions & 4 deletions tests/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ fn test_view_conversion()
fn test_view_conversion_lifetime()
{
// Regression test for #1595
struct Foo<'a> {
struct Foo<'a>
{
data: ArrayViewMut2<'a, f32>,
}

impl<'a> Foo<'a> {
fn into_shared(self) -> ArrayView2<'a, f32> {
impl<'a> Foo<'a>
{
fn into_shared(self) -> ArrayView2<'a, f32>
{
self.data.into_view()
}

fn into_shared_from(self) -> ArrayView2<'a, f32> {
fn into_shared_from(self) -> ArrayView2<'a, f32>
{
self.data.into()
}
}
Expand Down
Loading