-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mapv_into_any doesn't respect storage type #1280
Comments
I didn't think about Also, BTW, |
mapv_into_any has the same limitations as map, map_mut, and mapv and mapv_into is the odd one (!) It would be nice to solve but you sort of get into type system limitations, don't you? |
Just want to do
Those methods don't take array by ownership so I don't think they're comparable.
Not in this case tbh. I think it can be generic over |
Mapv_into_any does not use the same signature as mapv_into, because the element type changes. We get into the general Rust problem of translating " You might see that the incoming storage type is "S" in If we look elsewhere in Rust, "Vec" is not a type, but " We know how to do some array kind-preserving but element mapping operations, we have https://docs.rs/ndarray/latest/ndarray/struct.ArrayBase.html#method.assume_init which does this after all, but I think it's kind of awkward. Would be great to see what the solution would look like here. |
Sure, but |
If you don't want my input on where challenges might lie - I've worked with these kinds of issues in ndarray before after all, when writing most of the crate - then maybe attempting an implementation and seeing what works in practice is a good way to go. |
That... sounds unnecessarily hostile, but sure, I'm happy to give it a stab. I just thought @benkay86 might be more interested hence the issue. |
Ah and yeah I see what you meant, but now that we have higher-kinder associated types I think K this might be still doable. If not, another type param could be just arbitrary storage destination. The bigger problem is that one way or another this would be a breaking change at this point, as someone might rely on output being always Array, so I guess this would require a yet another separate function. |
@bluss, happy to see you active on GitHub! Ndarray is a really valuable project, happy to see it hasn't been completely abandoned. OK, I took a stab at this with #1283. Looks OK except for pre-existing issues with CI and clippy. This is a breaking change that will require users to call |
@benkay86 This is great, thanks! It's pretty much what I had in mind with making it generic over return type but I had the same concerns about backward compatibility so wanted to hear back on those first. Appreciate you implementing it though! |
FWIW another option I was thinking about was just moving this method to specialised This would allow the caller to avoid specifying return type as a param, always returning same storage type as input, but would make it less flexible so not sure it's worth it. |
I don't quite have the bandwidth. I'd like to bring in new people to maintain, if it can be done. |
Unlike
mapv_into
,mapv_into_any
currently always returns a heap-allocatedArray
even if the source is something else - in my case,ArcArray
.It would be great if, like
mapv_into
, it was generic over storage types and allowed to cloneArcArray
in-place when no copy is necessary.cc @benkay86 who added it in the first place
The text was updated successfully, but these errors were encountered: