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

Implement From<A2> for SmallVec<A1> for all A2, A1 with the same Item (v1) #339

Closed
wants to merge 1 commit into from

Conversation

zachs18
Copy link
Contributor

@zachs18 zachs18 commented Feb 19, 2024

#338 backported to v1

With opt-level >= 1, Rust appears to reliably compile this PR to either a basically just memcpy (for M <= N) or an alloc and a memcpy (for M > N)

Resolves #272

@zachs18 zachs18 changed the title Implement From<[T; M]> for SmallVec<[T; N]> for all M, N (v1) Implement From<A2> for SmallVec<A1> for all A2, A1 with the same Item (v1) Feb 19, 2024
@mbrubeck
Copy link
Collaborator

mbrubeck commented Feb 19, 2024

One downside: The following program used to compile, but now fails because the type of _v cannot be inferred:

fn main() {
    let _v = smallvec::SmallVec::from([true]);
}

This is still considered a minor change by Rust’s versioning conventions, but if it’s likely to break code in the wild then I might prefer to keep this as a v2-only change.

Using SmallVec::from([a, b, c]) seems like a plausible way to construct a SmallVec, but I don’t know if it’s at all common in practice.

@mbrubeck
Copy link
Collaborator

I'm going to be conservative and close this PR, to avoid breaking any v1 users. The new functionality will be available in v2. Thanks again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants