-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
correct String(array) docs #25846
correct String(array) docs #25846
Conversation
(I tend to think we should document |
This method already exists a few lines below. |
Whoops, I didn't notice that you already added that method; I removed the redundancy. |
Thanks for documenting this. Though I must say that reading the description of the behavior, it doesn't feel satisfying. Apart from being inconsistent, it's dangerous because you can't know whether a vector passed by a caller has been allocated by e.g. That said, better merge the PR since it describes what currently happens. |
That issue was about preventing mutation of strings via vectors, which the current behavior accomplishes. |
Resolved a merge conflict. Okay to merge? |
This PR is mostly obsolete, and now boils down to a 1-line clarification to the docs. Should be fine to merge. |
I noticed that the
String(::Vector{UInt8})
docs stated thatString(array)
always takes "ownership" of the data. This is no longer true in 0.7 except for arrays allocated withStringVector
.This PR corrects the
String(array)
docs to accurately describe the circumstances in whichString
takes ownership of the array (currentlytake!
andread
are the only documented ways as far as I can tell), and the fact that the length of the array is set to0
in such cases.Also, since(Whoops, this method was already added.)String
generally makes a copy for an arbitraryVector{UInt8}
, I saw no reason not to expand the constructor to acceptAbstractVector{UInt8}
(previously aMethodError
).See also #24388 (comment)