ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Add From impls for CowArray, similar to Array and ArrayView

Open jturner314 opened this issue 4 years ago • 1 comments

Discussed in https://github.com/rust-ndarray/ndarray/discussions/1036

Originally posted by hombit June 18, 2021 Is there any reason why CowArray doesn't implement all From which is implemented by both Array and ArrayView? My current usage is limited to build CowArray from both &Vec and Vec, but generally I'd like to write something like:

struct S<'a> {
    ca: CowArray<'a, f64, Ix1>
}

impl<'a> S<'a> {
    fn new(a: impl Into<CowArray<'a, f64, Ix1>>) -> Self {
        Self {ca: a.into()}
    }
}

jturner314 avatar Jun 18 '21 16:06 jturner314

Two PRs will resolve this:

  • Conversions from owned types: #1028
  • Conversions from slices/references: #1038

jturner314 avatar Jun 18 '21 16:06 jturner314