-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add ArrayVecCopy
#280
base: master
Are you sure you want to change the base?
Add ArrayVecCopy
#280
Conversation
6c7c12b
to
2547adf
Compare
hi, intriguing. I'm skeptical of the maintainability, but it could work, it's a nice accomplishment and not a bad flow you have set up. The more sed patterns needed the worse of a solution this is, I guess? |
2547adf
to
2939f31
Compare
Fixes bluss#32.
03fb484
to
abf40d5
Compare
It works by replacing a couple of strings in `src/arrayvec.rs` and then applying a small patch. Check that the patch is up-to-date in CI.
They don't work on Rust 1.51 ``` error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable --> src/arrayvec_copy.rs:59:6 | 59 | impl<T: Copy, const CAP: usize> ArrayVecCopy<T, CAP> { | ^ | = note: see issue #57563 <rust-lang/rust#57563> for more information = help: add `#![feature(const_fn)]` to the crate attributes to enable ```
abf40d5
to
6a182a2
Compare
Yeah. :( I wanted to document the They are, in that order: |
Theoretically, it should be as simple as making the change, then deleting |
It's promising. I'm suggesting this creative way of not having to have a patch at all. Instead insert our own directives into the code using comments, and use |
Invent this little hack, insert directives like this in ArrayVec: ```rust // DIRECTIVE ArrayVecCopy #[cfg(not_in_arrayvec_copy)] ``` And replace them as follows in ArrayVecCopy: ```rust #[cfg(not_in_arrayvec_copy)] ```
It's a type nested in a function, does not need renaming.
It all came together very nicely. How to add Copy-specific features is going to be figured out when that bridge needs to be crossed. I think the PR is really good now except that ArrayVecCopy is not actually Copy 😆 which I hope we take with some humor. How do I know, well I'm just adding a basic test for that before merging.. I'm pushing a fix for that and a basic test now. |
The final decoration on the top of the pyramid.
Have to think more about the module structure. Maybe ArrayVecCopy should just live inside arrayvec::copy. It would be somewhat consistent when the iterator structs need to have that namespace anyway. |
Oh my god…
Thanks for remembering to add tests, which I conveniently forgot…
It'd make it more inconvenient to import |
Maybe the editing here is missing "the outside perspective from cargo doc" part of the review. Generate doc, look at it, we see stuff we need to add -> module doc for copy and main module doc needs to mention ArrayVecCopy because it's strange if it doesn't. I'm still leaning towards that ArrayVecCopy should be down in its copy module, it's more consistent that way, and we have the chance to do it right now. |
Can you explain what your proposed module structure is?
If I understand you correctly, you propose 1. I implemented it as 3. I think the choice of 1 would lead to more (duplicate!) typing because the name specifies "copy" twice: I'd prefer 2 or 3 over 1, I think the standard library does 2, and I'd do 3 so that we only have one possible import path for |
I would prefer (1) or (2). I think (1) is on balance the better choice? I don't mind the duplicate |
Implemented (1). |
9c19f78
to
825e154
Compare
This is asymmetrical towards |
Also add infrastructure to generate
src/arrayvec_copy.rs
. It works by replacing a couple of strings insrc/arrayvec.rs
.Check that the transformation is up-to-date in CI.
Fixes #32.
Closes #261.