<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/library/alloc/tests/string.rs, branch 1.56.1</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.56.1</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.56.1'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2021-08-07T13:48:27+00:00</updated>
<entry>
<title>Use assert_matches! instead of if let {} else</title>
<updated>2021-08-07T13:48:27+00:00</updated>
<author>
<name>Kornel</name>
<email>kornel@geekhood.net</email>
</author>
<published>2021-08-07T11:51:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7dca8eb5653fb7ae5efbea2b80941997fead5ce3'/>
<id>urn:sha1:7dca8eb5653fb7ae5efbea2b80941997fead5ce3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Hide allocator details from TryReserveError</title>
<updated>2021-07-24T21:25:08+00:00</updated>
<author>
<name>Kornel</name>
<email>kornel@cloudflare.com</email>
</author>
<published>2021-07-23T15:40:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a294aa8d3d7b73b7de60c629ae202194cffeb2f4'/>
<id>urn:sha1:a294aa8d3d7b73b7de60c629ae202194cffeb2f4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Implement String::remove_matches</title>
<updated>2021-03-05T16:27:58+00:00</updated>
<author>
<name>Josh Cotton</name>
<email>jcotton42@outlook.com</email>
</author>
<published>2021-03-05T16:27:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a2571cfc8b6f5cf5d8d2e7075ac4809aceae9541'/>
<id>urn:sha1:a2571cfc8b6f5cf5d8d2e7075ac4809aceae9541</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix soundness issue for `replace_range` and `range`</title>
<updated>2021-01-19T03:14:38+00:00</updated>
<author>
<name>dylni</name>
<email>46035563+dylni@users.noreply.github.com</email>
</author>
<published>2021-01-19T03:14:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b96063cf4757eb698611b57e9032da2b74c8c789'/>
<id>urn:sha1:b96063cf4757eb698611b57e9032da2b74c8c789</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Added test for issue #78498</title>
<updated>2020-10-29T11:25:02+00:00</updated>
<author>
<name>Giacomo Stevanato</name>
<email>giaco.stevanato@gmail.com</email>
</author>
<published>2020-10-29T10:48:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1f6f917f73a4372f098e9b19560b5945be145dc3'/>
<id>urn:sha1:1f6f917f73a4372f098e9b19560b5945be145dc3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Use `T::BITS` instead of `size_of::&lt;T&gt; * 8`.</title>
<updated>2020-09-19T04:54:42+00:00</updated>
<author>
<name>Mara Bos</name>
<email>m-ou.se@m-ou.se</email>
</author>
<published>2020-09-08T19:39:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1e2dba1e7cf15442257f2cd3ddfe5d0462ee9102'/>
<id>urn:sha1:1e2dba1e7cf15442257f2cd3ddfe5d0462ee9102</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #75882 - pickfire:patch-6, r=jyn514</title>
<updated>2020-09-15T23:30:36+00:00</updated>
<author>
<name>Dylan DPC</name>
<email>dylan.dpc@gmail.com</email>
</author>
<published>2020-09-15T23:30:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c9105185de5bdaf278bd8febcd34b778151293f5'/>
<id>urn:sha1:c9105185de5bdaf278bd8febcd34b778151293f5</id>
<content type='text'>
Use translated variable for test string

Test should be educative, added english translation and pronounciation.
</content>
</entry>
<entry>
<title>Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum</title>
<updated>2020-09-15T23:30:30+00:00</updated>
<author>
<name>Dylan DPC</name>
<email>dylan.dpc@gmail.com</email>
</author>
<published>2020-09-15T23:30:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=fb9bb2b5ca517d85e1041ea9f80d06f48054624c'/>
<id>urn:sha1:fb9bb2b5ca517d85e1041ea9f80d06f48054624c</id>
<content type='text'>
Detect overflow in proc_macro_server subspan

* Detect overflow in proc_macro_server subspan
* Add tests for overflow in Vec::drain
* Add tests for overflow in String / VecDeque operations using ranges
</content>
</entry>
<entry>
<title>Optimize behavior of vec.split_off(0) (take all)</title>
<updated>2020-09-13T21:32:29+00:00</updated>
<author>
<name>Rich Kadel</name>
<email>richkadel@google.com</email>
</author>
<published>2020-09-13T18:58:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=79aa9b15d7403ce2dc40b525a1d16e6c4ad1973c'/>
<id>urn:sha1:79aa9b15d7403ce2dc40b525a1d16e6c4ad1973c</id>
<content type='text'>
Optimization improvement to `split_off()` so the performance meets the
intuitively expected behavior when `at == 0`, avoiding the current
behavior of copying the entire vector.

The change honors documented behavior that the method leaves the
original vector's "previous capacity unchanged".

This improvement better supports the pattern for building and flushing a
buffer of elements, such as the following:

```rust
    let mut vec = Vec::new();
    loop {
        vec.push(something);
        if condition_is_met {
            process(vec.split_off(0));
        }
    }
```

`Option` wrapping is the first alternative I thought of, but is much
less obvious and more verbose:

```rust
    let mut capacity = 1;
    let mut vec: Option&lt;Vec&lt;Stuff&gt;&gt; = None;
    loop {
        vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something);
        if condition_is_met {
            capacity = vec.capacity();
            process(vec.take().unwrap());
        }
    }
```

Directly applying `mem::replace()` could work, but `mem::` functions are
typically a last resort, when a developer is actively seeking better
performance than the standard library provides, for example.

The benefit of the approach to this change is it does not change the
existing API contract, but improves the peformance of `split_off(0)` for
`Vec`, `String` (which delegates `split_off()` to `Vec`), and any other
existing use cases.

This change adds tests to validate the behavior of `split_off()` with
regard to capacity, as originally documented, and confirm that behavior
still holds, when `at == 0`.

The change is an implementation detail, and does not require a
documentation change, but documenting the new behavior as part of its
API contract may benefit future users.

(Let me know if I should make that documentation update.)

Note, for future consideration:

I think it would be helpful to introduce an additional method to `Vec`
(if not also to `String`):

```
    pub fn take_all(&amp;mut self) -&gt; Self {
        self.split_off(0)
    }
```

This would make it more clear how `Vec` supports the pattern, and make
it easier to find, since the behavior is similar to other `take()`
methods in the Rust standard library.
</content>
</entry>
<entry>
<title>Move test-cases in string.rs</title>
<updated>2020-09-06T03:53:40+00:00</updated>
<author>
<name>Ayush Kumar Mishra</name>
<email>ayush.k.mishra@xcelenergy.com</email>
</author>
<published>2020-09-06T03:53:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=05d22c8519f5c29436a26d0bc47734bcf51a4dcd'/>
<id>urn:sha1:05d22c8519f5c29436a26d0bc47734bcf51a4dcd</id>
<content type='text'>
</content>
</entry>
</feed>
