<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_data_structures/src/thin_vec, branch master</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=master</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=master'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2022-08-29T05:42:13+00:00</updated>
<entry>
<title>Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.</title>
<updated>2022-08-29T05:42:13+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2022-08-17T04:22:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b38106b6d8478fbfbded5403ee31c056c71cef48'/>
<id>urn:sha1:b38106b6d8478fbfbded5403ee31c056c71cef48</id>
<content type='text'>
`rustc_data_structures::thin_vec::ThinVec` looks like this:
```
pub struct ThinVec&lt;T&gt;(Option&lt;Box&lt;Vec&lt;T&gt;&gt;&gt;);
```
It's just a zero word if the vector is empty, but requires two
allocations if it is non-empty. So it's only usable in cases where the
vector is empty most of the time.

This commit removes it in favour of `thin_vec::ThinVec`, which is also
word-sized, but stores the length and capacity in the same allocation as
the elements. It's good in a wider variety of situation, e.g. in enum
variants where the vector is usually/always non-empty.

The commit also:
- Sorts some `Cargo.toml` dependency lists, to make additions easier.
- Sorts some `use` item lists, to make additions easier.
- Changes `clean_trait_ref_with_bindings` to take a
  `ThinVec&lt;TypeBinding&gt;` rather than a `&amp;[TypeBinding]`, because this
  avoid some unnecessary allocations.
</content>
</entry>
<entry>
<title>eplace usages of vec![].into_iter with [].into_iter</title>
<updated>2022-01-09T03:09:25+00:00</updated>
<author>
<name>Lucas Kent</name>
<email>rubickent@gmail.com</email>
</author>
<published>2021-12-17T07:36:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=08829853d3c69f68a5a09fb4bcc53ca87d373a78'/>
<id>urn:sha1:08829853d3c69f68a5a09fb4bcc53ca87d373a78</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add `FromIterator` and `IntoIterator` impls for `ThinVec`</title>
<updated>2021-04-06T02:09:51+00:00</updated>
<author>
<name>Camelid</name>
<email>camelidcamel@gmail.com</email>
</author>
<published>2021-04-03T02:56:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=09ff88b600713a2bfca7cfdfd1828b519c907247'/>
<id>urn:sha1:09ff88b600713a2bfca7cfdfd1828b519c907247</id>
<content type='text'>
These should make using `ThinVec` feel much more like using `Vec`.
They will allow users of `Vec` to switch to `ThinVec` while continuing
to use `collect()`, `for` loops, and other parts of the iterator API.

I don't know if there were use cases before for using the iterator API
with `ThinVec`, but I would like to start using `ThinVec` in rustdoc,
and having it conform to the iterator API would make the transition
*a lot* easier.

I added a `FromIterator` impl, an `IntoIterator` impl that yields owned
elements, and `IntoIterator` impls that yield immutable or mutable
references to elements. I also added some unit tests for `ThinVec`.
</content>
</entry>
</feed>
