Skip to content

Commit

Permalink
update detailed design
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Orth committed Feb 18, 2015
1 parent 1a57d20 commit 24f772d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions text/0000-drain-range.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ Remove `Vec::drain` and add the following method:
///
/// Panics if the range is decreasing or if the upper bound is larger than the
/// length of the vector.
pub fn drain<T: Drainer>(&mut self, range: T) -> RangeIter<T> {
range.drain(self)
}
pub fn drain<T: Trait>(&mut self, range: T) -> /* ... */;
```

Where `Drainer` should be implemented for `Range<usize>`, `RangeTo<usize>`,
`RangeFrom<usize>`, `FullRange`, and `usize`.
Where `Trait` is some trait that is implemented for at least `Range<usize>`,
`RangeTo<usize>`, `RangeFrom<usize>`, `FullRange`, and `usize`.

The precise nature of the return value is to be determined during implementation
and may or may not depend on `T`.

Add `String::drain`:

Expand All @@ -77,11 +78,11 @@ Add `String::drain`:
/// Panics if the range is decreasing, if the upper bound is larger than the
/// length of the String, or if the start and the end of the range don't lie on
/// character boundaries.
pub fn drain(&mut self, range: /* ? */) -> /* ? */ {
// ?
}
pub fn drain<T: Trait>(&mut self, range: T) -> /* ... */;
```

Where `Trait` and the return value are as above but need not be the same.

# Drawbacks

- The function signature differs from other collections.
Expand Down

0 comments on commit 24f772d

Please sign in to comment.