D-Programming-Language/druntime — pull request #540 by monarchdodra (2013-07-08 07:32:30+00:00)
Title: assumeSafeAppend improvement

This pull improves assumeSafeAppend usage by making it return its argument. This is part of a bigger usability/usage fix for things like `appender` or functions that reuse buffers.

In particular, when making calls to things like `readln(buf)`: readln *will* relocate every time the current line is longer than the previous. For "true" buffer reuse, the user needs to pass in the buffer, while telling `readln` it is safe to append. Doing this inside a loop is not very convenient, if you have to do two instructions. The final goal here is to easily write code such as:

```D
char[] buf;
while(readln(assumeSafeAppend(buf))
{ ... }
```

or just plain more UFCS friendliness.

```D
T[] someBuffer = initialize() ;
auto app = someBuffer[0 .. $/2].assumeSafeAppend.appender();
```

--------
Two sigs for byValue/byRef (auto ref don't work cause it will escape a ref to a local variable). Tweaks doc. Improves unittest.