Skip to content

Final pre-alpha stabilization of: iter, ops, slice, collections #20560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

aturon
Copy link
Member

@aturon aturon commented Jan 5, 2015

Now that various language features have been rolled out and RFCs implemented, this PR takes a final stabilization pass over iter, ops, slice and collections.

Commit summaries copied below:

Final alpha stabilization of core::iter

This commit wraps up the adjustments to the iterator for recent language
changes.

  • Moves rposition from ExactSizeIterator to IteratorExt using a
    where clause, thereby removing the ExactSizeIterator: DoubleEndedIterator constraint.
  • Merges MutableDoubleEndedIterator into IteratorExt, renaming
    reverse_ to reverse_in_place.
  • Merges IteratorOrdExt, IteratorCloneExt and CloneIteratorExt
    into IteratorExt using where clauses.

Marks as #[stable]:

  • the iter module itself
  • FromIterator, Extend
  • Iterator, IteratorExt
  • map
  • filter
  • filter_map
  • skip_while
  • take_while
  • scan
  • flat_map
  • inspect
  • collect
  • fold
  • all
  • any
  • find
  • rposition
  • max, min
  • Various adapter types related to the above methods

Because of the trait merging, this is a:

[breaking-change]

Stabilize core::ops

This commit marks as stable those parts of core::ops that are in their
final planned form: Drop, all of the mathematical operators (Add,
Sub, etc), Deref/DerefMut. It leaves the Index*, Slice* and
Fn* traits unstable, as they are still undergoing active changes.

Final alpha stabilization of std::slice

Marks as #[stable]:

  • Various iterator structs for stable methods, e.g. Chunks and
    Windows.
  • The SliceExt trait itself.

Stabilize collection modules

The earlier collections stabilization did not cover the modules
themselves. This commit marks as stable those modules whose types have
been stabilized.

Stabilization of impls and fallout from stabilization

Stabilizes impls of now-stable traits.

@rust-highfive
Copy link
Contributor

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@aturon
Copy link
Member Author

aturon commented Jan 5, 2015

r? @alexcrichton

@aturon
Copy link
Member Author

aturon commented Jan 5, 2015

(We should probably wait to land this until we've had a chance to discuss Iterator again.)

@@ -418,7 +418,7 @@ impl<T: Sync + Send> Clone for Weak<T> {
}

#[unsafe_destructor]
#[experimental = "Weak pointers may not belong in this module."]
#[stable]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any notes on this call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't read anything into the #[stable] here other than: if we have Weak, we'll keep the Drop impl.

@aturon aturon force-pushed the stab-2-iter-ops-slice branch from c11d268 to ee5109b Compare January 5, 2015 06:13
@aturon
Copy link
Member Author

aturon commented Jan 5, 2015

@gankro pushed a revision marking the correct hash_map modules. I think the markers within libcollections were already OK. Double-check my work?

fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
}

/// Conversion from an `Iterator`
#[unstable = "may be replaced by a more general conversion trait"]
#[stable]
pub trait FromIterator<A> {
/// Build a container with elements from an external iterator.
fn from_iter<T: Iterator<Item=A>>(iterator: T) -> Self;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems slightly odd to still have a type parameter now that Item is an associated type, but I suppose T: Iterator doesn't tell you much and you need to write down the Item type somewhere.

Just confirming.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is desired to allow types to be created (or extended) via iterators from multiple items. For example, String can be extended by char or &str iterators.

@alexcrichton
Copy link
Member

This looks great to me, this is all really falling into place!

@Gankra
Copy link
Contributor

Gankra commented Jan 5, 2015

Also should we explicitly mark the other modules as unstable with a reason?

@alexcrichton
Copy link
Member

This should also add #![stable] to the slice module itself.

aturon added 2 commits January 5, 2015 14:01
This commit wraps up the adjustments to the iterator for recent language
changes.

* Moves `rposition` from `ExactSizeIterator` to `IteratorExt` using a
  `where` clause, thereby removing the `ExactSizeIterator:
  DoubleEndedIterator` constraint.

* Merges `MutableDoubleEndedIterator` into `IteratorExt`, renaming
  `reverse_` to `reverse_in_place`.

* Merges `IteratorOrdExt`, `IteratorCloneExt` and `CloneIteratorExt`
  into `IteratorExt` using `where` clauses.

Marks as `#[stable]`:

* the `iter` module itself
* `FromIterator`, `Extend`
* `Iterator`, `IteratorExt`
* `map`
* `filter`
* `filter_map`
* `skip_while`
* `take_while`
* `scan`
* `flat_map`
* `inspect`
* `collect`
* `fold`
* `all`
* `any`
* `find`
* `rposition`
* `max`, `min`
* Various adapter types related to the above methods

Because of the trait merging, this is a:

[breaking-change]
This commit marks as stable those parts of `core::ops` that are in their
final planned form: `Drop`, all of the mathematical operators (`Add`,
`Sub`, etc), `Deref`/`DerefMut`. It leaves the `Index*`, `Slice*` and
`Fn*` traits unstable, as they are still undergoing active changes.
@aturon aturon force-pushed the stab-2-iter-ops-slice branch from ee5109b to 5371ae2 Compare January 5, 2015 22:08
aturon added 2 commits January 5, 2015 14:08
Marks as `#[stable]`:

* Various iterator structs for stable methods, e.g. `Chunks` and
  `Windows`.
* The `SliceExt` trait itself.
The earlier collections stabilization did not cover the modules
themselves. This commit marks as stable those modules whose types have
been stabilized.
@aturon
Copy link
Member Author

aturon commented Jan 5, 2015

@alexcrichton updated. After a bunch of discussion on the topic, I think we should move forward stabilizing Iterator as in this PR. r?

@alexcrichton
Copy link
Member

Looks like rust-installer was reverted, but r=me otherwise

@aturon
Copy link
Member Author

aturon commented Jan 5, 2015

I hate submodules 💢

@aturon aturon force-pushed the stab-2-iter-ops-slice branch from 5371ae2 to c6f4a03 Compare January 5, 2015 22:26
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 6, 2015
Conflicts:
	src/libcollections/slice.rs
	src/libcore/iter.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/rwlock.rs
@aturon aturon force-pushed the stab-2-iter-ops-slice branch from c6f4a03 to 107fe6e Compare January 6, 2015 08:17
@alexcrichton
Copy link
Member

Landed in #20610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants