Skip to content

Commit f64a478

Browse files
aturonalexcrichton
authored andcommitted
Update with minor clarifications and adjustments
1 parent 0fe669d commit f64a478

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

active/0000-collections-conventions.md renamed to text/0000-collection-conventions.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ Operation | Collections
975975
`fn insert(&mut self, K::Owned) -> bool` | `HashSet`, `TreeSet`, `TrieSet`, `BitvSet`
976976
`fn insert(&mut self, K::Owned, V) -> Option<V>` | `HashMap`, `TreeMap`, `TrieMap`, `SmallIntMap`
977977
`fn append(&mut self, Self)` | `DList`
978+
`fn prepend(&mut self, Self)` | `DList`
978979

979980
There are a few changes here from the current state of affairs:
980981

@@ -1238,13 +1239,13 @@ fn difference<'a>(&'a self, other: &'a Self) -> I;
12381239
fn symmetric_difference<'a>(&'a self, other: &'a Self) -> I;
12391240
```
12401241

1241-
where the `I` type is an iterator over keys that varies by concrete set. Working
1242-
with these iterators avoids materializing intermediate sets when they're not
1243-
needed; the `collect` method can be used to create sets when they are.
1244-
1245-
To clarify the API, this RFC proposes renaming the methods to `iter_or`,
1246-
`iter_and`, `iter_sub`, and `iter_xor` respectively. These names emphasize the
1247-
fact that the methods return iterators, which may be surprising.
1242+
where the `I` type is an iterator over keys that varies by concrete
1243+
set. Working with these iterators avoids materializing intermediate
1244+
sets when they're not needed; the `collect` method can be used to
1245+
create sets when they are. This RFC proposes to keep these names
1246+
intact, following the
1247+
[RFC](https://github.com/rust-lang/rfcs/pull/344) on iterator
1248+
conventions.
12481249

12491250
Sets should also implement the `BitOr`, `BitAnd`, `BitXor` and `Sub` traits from
12501251
`std::ops`, allowing overloaded notation `|`, `&`, `|^` and `-` to be used with
@@ -1487,13 +1488,15 @@ v.push_all_move(some_vec);
14871488
v.extend(some_vec);
14881489
```
14891490

1490-
However, currently the `push_all` and `push_all_move` methods can rely on the
1491-
*exact* size of the container being pushed, in order to elide bounds checks. We
1492-
do not currently have a way to "trust" methods like `len` on iterators to elide
1493-
bounds checks. A separate RFC will introduce the notion of a "trusted" method
1494-
which should support such optimization and allow us to deprecate the `push_all`
1495-
and `push_all_move` variants. (This is unlikely to happen before 1.0, so the
1496-
methods will probably still be included with "experimental" status.)
1491+
However, currently the `push_all` and `push_all_move` methods can rely
1492+
on the *exact* size of the container being pushed, in order to elide
1493+
bounds checks. We do not currently have a way to "trust" methods like
1494+
`len` on iterators to elide bounds checks. A separate RFC will
1495+
introduce the notion of a "trusted" method which should support such
1496+
optimization and allow us to deprecate the `push_all` and
1497+
`push_all_move` variants. (This is unlikely to happen before 1.0, so
1498+
the methods will probably still be included with "experimental"
1499+
status, and likely with different names.)
14971500

14981501
# Alternatives
14991502

@@ -1767,4 +1770,5 @@ Using the `Borrow` trait, it might be possible to safely add a coercion for auto
17671770
For sized types, this coercion is *forced* to be trivial, so the only time it
17681771
would involve running user code is for unsized values.
17691772

1770-
A general story about such coercions will be left to a follow-up RFC.
1773+
A general story about such coercions will be left to a
1774+
[follow-up RFC](https://github.com/rust-lang/rfcs/pull/241).

0 commit comments

Comments
 (0)