X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibcore%2Fiter%2Ftraits%2Fcollect.rs;h=4a90aca148547b81b6003989dfbdcd6c7cb1e361;hb=e4345547b967a1fed4d62f6f0c539b56a2131aa4;hp=f21ab8dbc3737d180629262b0f42cf345cbd635d;hpb=873ddf7da064ed68239de8a856049732bda69a1f;p=rust.git
diff --git a/src/libcore/iter/traits/collect.rs b/src/libcore/iter/traits/collect.rs
index f21ab8dbc37..4a90aca1485 100644
--- a/src/libcore/iter/traits/collect.rs
+++ b/src/libcore/iter/traits/collect.rs
@@ -322,7 +322,7 @@ fn into_iter(self) -> I {
pub trait Extend {
/// Extends a collection with the contents of an iterator.
///
- /// As this is the only method for this trait, the [trait-level] docs
+ /// As this is the only required method for this trait, the [trait-level] docs
/// contain more details.
///
/// [trait-level]: trait.Extend.html
@@ -341,6 +341,20 @@ pub trait Extend {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn extend>(&mut self, iter: T);
+
+ /// Extends a collection with exactly one element.
+ #[unstable(feature = "extend_one", issue = "none")]
+ fn extend_one(&mut self, item: A) {
+ self.extend(Some(item));
+ }
+
+ /// Reserves capacity in a collection for the given number of additional elements.
+ ///
+ /// The default implementation does nothing.
+ #[unstable(feature = "extend_one", issue = "none")]
+ fn extend_reserve(&mut self, additional: usize) {
+ let _ = additional;
+ }
}
#[stable(feature = "extend_for_unit", since = "1.28.0")]
@@ -348,4 +362,5 @@ impl Extend<()> for () {
fn extend>(&mut self, iter: T) {
iter.into_iter().for_each(drop)
}
+ fn extend_one(&mut self, _item: ()) {}
}