Skip to content
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

Rust slice #10

Closed
programmerjake opened this issue Jan 16, 2020 · 4 comments
Closed

Rust slice #10

programmerjake opened this issue Jan 16, 2020 · 4 comments
Labels
help wanted new binding Involves adding a new public type to cxx crate or rust/cxx.h header

Comments

@programmerjake
Copy link

Maybe std::span could be used as the translation of a Rust slice

@programmerjake
Copy link
Author

You could use &[T] -> std::span<const T> and &mut [T] -> std::span<T>.

@bitwalker
Copy link

Yeah this is the main thing holding me back at the moment myself, I have code I'd like to port to use cxx, but it involves passing around slices/vectors frequently.

I started looking into what an implementation would take, and I don't think it would be too difficult to get something working, but unfortunately I can't spare the time at the moment, so I'll have to revisit in a few weeks and see if things are still in limbo.

RE: std::span - it is only in C 20, so I don't think it's the best option in the near term (though it could be conditionally enabled if available). I'd think something akin to the way &str is handled would apply here. As long as the C implementation provides the iterator traits, it wouldn't make much of a difference in ergonomics.

@adetaylor
Copy link
Collaborator

I made an attempt at some progress here: #117

@dtolnay dtolnay added help wanted new binding Involves adding a new public type to cxx crate or rust/cxx.h header labels Apr 28, 2020
@dtolnay
Copy link
Owner

dtolnay commented Nov 30, 2020

&[u8] support was released in cxx 0.2.9, &mut [u8] in 1.0.3, and &[T] / &mut [T] for T!=u8 in 1.0.5, so we should be all done here!

@dtolnay dtolnay closed this as completed Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted new binding Involves adding a new public type to cxx crate or rust/cxx.h header
Projects
None yet
Development

No branches or pull requests

4 participants