-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Settle conventions for ~str/StrBuf, ~[T]/Vec #13717
Comments
I strongly believe the types that retain more information, and are more flexible ( I know this is controversial and others would (somewhat) prefer the |
If we're ignoring performance and size considerations, I don't think There's no allocator parameter on the current unique pointers, but under the assumption that a future Conversions from If our allocators take a mandatory size parameter when deallocating like C++ allocators then there's also a need to drop the excess capacity with |
Hm, let me try to making a bullet list of all relevant aspects and assumptions that influence this decision. This is going to be a bit train-of-though-y, and not based on first-hand experience, so I might be talking bullshit or consider unimportant details. ;) I'm assuming So, as far as I can see at least these aspects are important:
If it where just about 1-3, then the logical choice would be that everything that returns a vector that could conceivably have excess capacity (due to incremental build-up or similar) return a If you also consider 4, then the choice of using 5 might be a argument in favor of But, there is also 6 and 7 to think about: Rust is already a complex language, so any convention a new user of the language has to learn up front should be as simple as is practical. And arrays and vectors, while being as basic as it gets, already are more complex than in other languages due to unsized For 8, if the convention becomes to choose between The problem with 9 is that a wrongly used Lastly, with 10 I think this is the same "provide short, intuitive build-in syntax for common structures" desire that gets expressed every time language features move into the library or get more generic. Certain things simply look way more verbose in todays rust than in that of one, two years ago, so every time a new verbosity/complexity develops, people try to find ways to minimize its impact. (I remember falling into the same trap at the time removing So in conclusion I think using |
One concern I had recently is what to do about string literals. I would imagine that the type of a string literal will very much wish itself to be the default string type (whatever it is). If the default string type were |
About string literals, keep in mind that you can have unsized values under DST, as long as they're lvalues. Under DST, with the current types, I would expecting boxing such a |
I don't think the literal should be allocating memory. There's always a string slice involved, and I think dynamically allocating memory and copying from the string slice might as well be explicit. The literals for ~str are already going to be gone so StrBuf is no different. |
Ah, I found a better way to phrase my concern. In the original DST proposal, Competing proposals sounds like they want to answer the question: |
I think array ( I wouldn't mind just doing something similar for strings and using |
P-backcompat-libs 1.0 |
@alexcrichton I was just idly wondering about the names here. As a Lisper, I like Having said that, I do not mind @thestinger 's suggestion of |
I think I think part of the difficulty here is that, while there are plenty of words to choose from for vector-like containers, almost all languages have called strings strings. Any string-like type that does not have string in the name will be at a disadvantage relative to the one that does. |
@zkamsler Its hard in general to mutate Rust (utf8) strings while leaving their length unchanged. My intuition is that for the string analogue to |
You'll still be able to perform all of the |
…eykril Handle raw identifiers in proc macro server Fixes rust-lang#13706 When proc macros create `proc_macro::Ident`s, they pass an identifier text without "r#" prefix and a flag `is_raw` to proc macro server. Our `tt::Ident` currently stores the text *with* "r#" so we need to adjust them somewhere. Rather than following rustc and adding `is_raw` field to our `tt::Ident`, I opted for adjusting the representation of identifiers in proc macro server, because we don't need the field outside it. It's hard to write regression test for this, but at least I: - ran `cargo +nightly t --features sysroot-abi` and all the tests passed - built proc macro server with `cargo +nightly b -r --bin rust-analyzer-proc-macro-srv --features sysroot-abi` and made sure rust-lang#13706 resolved - For the record, the nightly versions used are `rustc 1.67.0-nightly (32e613b 2022-12-02)` and `cargo 1.67.0-nightly (e027c4b5d 2022-11-25)`.
There's no consensus yet on when to use each. Nominating.
The text was updated successfully, but these errors were encountered: