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

Tracking issue for `Vec::leak` #62195

Open
cramertj opened this issue Jun 27, 2019 · 3 comments

Comments

@cramertj
Copy link
Member

commented Jun 27, 2019

Similar to Box::leak, this function would allow leaking a Vec and getting back an &'a mut [T].

@jonas-schievink

This comment has been minimized.

Copy link
Member

commented Jun 27, 2019

Implementation in #62196

@SimonSapin

This comment has been minimized.

Copy link
Contributor

commented Sep 30, 2019

Box::leak is an associated function instead of a method to avoid shadowing a possible Foo::leak method in Box<Foo>, normally accessible through auto-deref.

This is less relevant to Vec::leak since Vec<T> dereferences to [T]. There is no [T]::leak method in the standard library, so making Vec::leak a method would only shadow such a method if it’s defined in a user trait.

@cramertj Do you think it should still be an associated function?

@cramertj

This comment has been minimized.

Copy link
Member Author

commented Sep 30, 2019

I don't have any particularly strong opinion. .leak() seems pretty clear to me, and users can always call it as Vec::leak if they prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.