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

Make vec::zip not require T:copy #3254

Closed
bblum opened this issue Aug 22, 2012 · 3 comments
Closed

Make vec::zip not require T:copy #3254

bblum opened this issue Aug 22, 2012 · 3 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone

Comments

@bblum
Copy link
Contributor

bblum commented Aug 22, 2012

Currently we have:

pure fn zip<T: copy, U: copy>(v: &[const T], u: &[const U]) -> ~[(T, U)]

Produces an "instantiating copy type parameter" warning when building stdtest.

We could instead have:

pure fn zip_ref<T: copy, U: copy>(v: &[const T], u: &[const U]) -> ~[(T, U)]
pure fn zip<T, U>(+v: ~[const T], +u: ~[const U]) -> ~[(T, U)]
@ghost ghost assigned catamorphism Aug 23, 2012
@catamorphism
Copy link
Contributor

I'm a bit puzzled about the second proposed function signature (for zip), as this doesn't allow the copy of v[i] and u[i] in vec::zip -- was your intention for zip to return a vector of pairs of references?

@bblum
Copy link
Contributor Author

bblum commented Aug 24, 2012

My thought was if zip owned its input, it would consume them when it put the elements in the new vector. something like:

pure fn zip<T, U>(+v: ~[const T], +u: ~[const U]) -> ~[(T, U)] {
    let i = len(v);
    assert i == len(u);
    let w = ~[];
    while i > 0 {
        push(w, (pop(v),pop(u)));
    }
    reverse(w);
    w
}

@ghost ghost assigned bblum Aug 24, 2012
@bblum bblum closed this as completed in dcbeebc Aug 24, 2012
@bblum
Copy link
Contributor Author

bblum commented Aug 24, 2012

I did unzip too. I renamed the existing ones to zip_slice and unzip_slice.

catamorphism pushed a commit to catamorphism/rust that referenced this issue Oct 8, 2012
@bblum bblum removed their assignment Jun 16, 2014
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jan 7, 2024
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
- Contracts cannot duplicate some attributes. I think we need a better
solution than just duplicate all attributes, but for now just filter the
ones we know are problematic.
- Do not make contract generated functions `const` when annotating
constant functions.
  - I also moved the compilation of no_core up since it is much faster.

## Call-out

Need to add a test.

Resolves rust-lang#3251 
Resolves rust-lang#3254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants