Commit Graph

3672 Commits

Author SHA1 Message Date
Eduard Burtescu
fe4fdcc0f6 core: make the public fmt API completely safe. 2014-12-08 09:14:21 +02:00
Eduard Burtescu
c75e8d46c2 core: remove the dead function fmt::argumentstr. 2014-12-08 09:14:21 +02:00
bors
f7d18b92f8 auto merge of #19407 : frewsxcv/rust/rm-reexports, r=cmr
In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::\*, Result::\*, and Ordering::\*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-07 04:12:20 +00:00
Alex Crichton
9b443289cf Register new snapshots 2014-12-05 15:39:26 -08:00
Corey Farwell
4ef16741e3 Utilize fewer reexports
In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::* and Result::*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-05 18:13:04 -05:00
Corey Richardson
090110779f rollup merge of #19553: sfackler/issue-19543
Closes #19543
2014-12-05 10:08:33 -08:00
Corey Richardson
c7d545e2f7 rollup merge of #19520: csouth3/derefmut-unsized
Right now, `DerefMut` is not `for Sized?`, so you can't impl `DerefMut<T> for Foo` where `Foo` is unsized.  However, there is no reason that it can't be `for Sized?`, so this pull request fixes the issue.

Closes #19493.
2014-12-05 10:07:47 -08:00
Corey Richardson
33e96be299 rollup merge of #19512: cybergeek94/master
Added the example from [this Reddit thread][1], reworked to be more robust with correct logic (first link skipped the 0th and 1st Fibonacci numbers, second forgot about the last two valid values before overflow). Will yield all Fibonacci numbers sequentially in the range `[0, <u32 as Int>::max_value())`.

If the example is too complicated I can change it to a more naive version, perhaps using signed integers to check for overflow instead of `Option` and `.checked_add()`.

Also reworded the doc comments to clarify the usage and behavior of `Unfold`, as the thread suggested that it wasn't really clear how `Unfold` worked and when one should use it.

This change is in the `core` crate but I based the example on `std` since that's where most readers will find the example. I included a note about `core` for clarity. Edit: removed.

Tested with `rustdoc src/libcore/lib.rs`. Rebased against latest master as of the creation of this PR.

[1]: http://www.reddit.com/r/rust/comments/2ny8r1/a_question_about_loops/cmighu4?context=10000
2014-12-05 10:07:41 -08:00
Corey Richardson
a6358f571e rollup merge of #19483: cgaebel/copy_memory-comment 2014-12-05 10:07:23 -08:00
Corey Richardson
560b8f6c59 rollup merge of #19468: victorvde/master
1. Made small improvements to the docs for checked_sub, checked_mul and checked_div.
2. Updated a confusingly outdated comment for intrinsics, noticed before at <https://stackoverflow.com/questions/23582931/>.
2014-12-05 10:07:07 -08:00
Corey Richardson
be75f2e090 rollup merge of #19386: tbu-/pr_refcell_stuff 2014-12-05 10:06:43 -08:00
Corey Richardson
9525af74a7 rollup merge of #19359: japaric/clone-cow
Now we can use `#[deriving(Clone)]` on structs that contain `Cow`.

r? @aturon or anyone else
2014-12-05 10:06:41 -08:00
Steven Fackler
714ce79197 Make missing_doc lint check typedefs
Closes #19543
2014-12-04 20:20:09 -08:00
bors
d9c7c00b9a auto merge of #18980 : erickt/rust/reader, r=erickt
This continues the work @thestinger started in #18885 (which hasn't landed yet, so wait for that to land before landing this one). Instead of adding more methods to `BufReader`, this just allows a `&[u8]` to be used directly as a `Reader`. It also adds an impl of `Writer` for `&mut [u8]`.
2014-12-04 21:33:07 +00:00
Erick Tryzelaar
298b525951 core: fix a doctest 2014-12-04 07:57:13 -08:00
bors
6d965cc2c9 auto merge of #19167 : japaric/rust/rhs-cmp, r=aturon
Comparison traits have gained an `Rhs` input parameter that defaults to `Self`. And now the comparison operators can be overloaded to work between different types. In particular, this PR allows the following operations (and their commutative versions):

- `&str` == `String` == `CowString`
- `&[A]` == `&mut [B]` == `Vec<C>` == `CowVec<D>` == `[E, ..N]` (for `N` up to 32)
- `&mut A` == `&B` (for `Sized` `A` and `B`)

Where `A`, `B`, `C`, `D`, `E` may be different types that implement `PartialEq`. For example, these comparisons are now valid: `string == "foo"`, and `vec_of_strings == ["Hello", "world"]`.

[breaking-change]s

Since the `==` may now work on different types, operations that relied on the old "same type restriction" to drive type inference, will need to be type annotated. These are the most common fallout cases:

- `some_vec == some_iter.collect()`: `collect` needs to be type annotated: `collect::<Vec<_>>()`
- `slice == &[a, b, c]`: RHS doesn't get coerced to an slice, use an array instead `[a, b, c]`
- `lhs == []`: Change expression to `lhs.is_empty()`
- `lhs == some_generic_function()`: Type annotate the RHS as necessary

cc #19148

r? @aturon
2014-12-04 12:02:56 +00:00
Austin Bonander
2e1911b47a core::iter::Unfold: reword docs and add example
Remove note about core
2014-12-04 01:28:16 -08:00
Chase Southwood
cddbb6a75b DerefMut should be for Sized? 2014-12-04 03:10:58 -06:00
Niko Matsakis
39221a013f Implement the Fn trait for bare fn pointers in the compiler rather than doing it using hard-coded impls. This means that it works also for more complex fn types involving bound regions. Fixes #19126. 2014-12-04 01:49:42 -05:00
Jorge Aparicio
5cfac94201 Deprecate Equiv 2014-12-03 10:41:48 -05:00
Jorge Aparicio
09707d70a4 Fix fallout 2014-12-03 10:41:48 -05:00
Jorge Aparicio
2840d58dab Overload the == operator
- String == &str == CowString
- Vec ==  &[T] ==  &mut [T] == [T, ..N] == CowVec
- InternedString == &str
2014-12-03 10:41:42 -05:00
Clark Gaebel
851c7b5e0f Fixed out of date comment on copy_memory 2014-12-02 17:50:26 -08:00
Jorge Aparicio
b258de7bda libcore: add Rhs input parameter to comparison traits 2014-12-02 18:52:50 -05:00
Victor van den Elzen
d8c5269dd2 Update comment to current file path for intrinsics 2014-12-02 20:57:00 +01:00
Victor van den Elzen
6182084e58 Improve documentation of checked_* functions 2014-12-02 20:56:41 +01:00
Erick Tryzelaar
0d24780793 std: add Reader impl for &[u8] 2014-11-30 16:55:53 -08:00
Tobias Bucher
5048953deb Simplify RefCell code a bit, make deref a no-op. 2014-11-30 11:50:35 +01:00
Jorge Aparicio
ddb77185d3 impl Clone for Cow 2014-11-27 09:04:20 -05:00
bors
82fc1aa875 auto merge of #19348 : SimonSapin/rust/patch-9, r=huonw 2014-11-27 10:11:19 +00:00
bors
66601647cd auto merge of #19343 : sfackler/rust/less-special-attrs, r=alexcrichton
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
2014-11-27 06:41:17 +00:00
Alex Crichton
e8d743ec1d rollup merge of #19329: steveklabnik/doc_style_cleanup2 2014-11-26 16:51:02 -08:00
Steve Klabnik
cd5c8235c5 /*! -> //!
Sister pull request of https://github.com/rust-lang/rust/pull/19288, but
for the other style of block doc comment.
2014-11-26 16:50:14 -08:00
Alex Crichton
f4a775639c rollup merge of #19298: nikomatsakis/unboxed-closure-parse-the-plus
Implements RFC 438.

Fixes #19092.

This is a [breaking-change]: change types like `&Foo+Send` or `&'a mut Foo+'a` to `&(Foo+Send)` and `&'a mut (Foo+'a)`, respectively.

r? @brson
2014-11-26 16:49:46 -08:00
Alex Crichton
f40fa8304f rollup merge of #19288: steveklabnik/doc_style_cleanup
This is considered good convention.

This is about half of them in total, I just don't want an impossible to land patch. 😄
2014-11-26 16:49:36 -08:00
Alex Crichton
34b98b306a rollup merge of #19287: alexcrichton/issue-19272
At the same time remove the `pub use` of the variants in favor of accessing
through the enum type itself. This is a breaking change as the `Found` and
`NotFound` variants must now be imported through `BinarySearchResult` instead of
just `std::slice`.

[breaking-change]
Closes #19271
2014-11-26 16:49:36 -08:00
Simon Sapin
104b3ab6a0 Update docstrings for UnicodeChar::is_digit => is_numeric rename 2014-11-26 23:42:54 +00:00
Steven Fackler
348cc9418a Remove special casing for some meta attributes
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
2014-11-26 11:44:45 -08:00
bors
1a44875af9 auto merge of #19176 : aturon/rust/stab-iter, r=alexcrichton
This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](rust-lang/rfcs#445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]
2014-11-26 17:42:07 +00:00
Niko Matsakis
f4e29e7e9a Fixup various places that were doing &T+'a and do &(T+'a) 2014-11-26 11:42:06 -05:00
Steve Klabnik
f38e4e6d97 /** -> ///
This is considered good convention.
2014-11-25 21:24:16 -05:00
Aaron Turon
b299c2b57d Fallout from stabilization 2014-11-25 17:41:54 -08:00
Aaron Turon
a86f72d9a2 libs: stabilize iter module
This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](https://github.com/rust-lang/rfcs/pull/445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]
2014-11-25 17:41:25 -08:00
Jorge Aparicio
3293ab14e2 Deprecate MaybeOwned[Vector] in favor of Cow 2014-11-25 11:22:23 -05:00
bors
f6cb58caee auto merge of #19149 : alexcrichton/rust/issue-19091, r=aturon
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename
non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all
`unwrap` methods are retained as `#[deprecated]` for the near future. To update
code rename `unwrap` method calls to `into_inner`.

[rfc]: https://github.com/rust-lang/rfcs/pull/430
[breaking-change]

cc #19091
2014-11-25 09:21:45 +00:00
bors
0c1d853fba auto merge of #18966 : huonw/rust/iter2slice, r=aturon
A slice iterator is isomorphic to a slice, just with a slightly
different form: storing start and end pointers rather than start pointer
and length. This patch reflects this by making converting between them
as easy as `iter.as_slice()` (or even `iter[]` if the shorter lifetime
is ok). That is, `slice.iter().as_slice() == slice`.

r? @aturon
2014-11-25 06:51:38 +00:00
Huon Wilson
b86a7808c7 Add methods to go from a slice iterators to a slice.
A slice iterator is isomorphic to a slice, just with a slightly
different form: storing start and end pointers rather than start pointer
and length. This patch reflects this by making converting between them
as easy as `iter.as_slice()` (or even `iter[]` if the shorter lifetime
is ok). That is, `slice.iter().as_slice() == slice`.
2014-11-25 17:10:32 +11:00
Alex Crichton
36372b929e std: Export BinarySearchResult
At the same time remove the `pub use` of the variants in favor of accessing
through the enum type itself. This is a breaking change as the `Found` and
`NotFound` variants must now be imported through `BinarySearchResult` instead of
just `std::slice`.

[breaking-change]
Closes #19272
2014-11-24 15:54:14 -08:00
bors
4334d3c196 auto merge of #19248 : japaric/rust/str, r=alexcrichton
Just like we do with AsSlice

This comes in handy when dealing with iterator-centric APIs (`IntoIterator`!) and you want to receive an `Iterator<S> where S: Str` argument. Without this PR, e.g. you can't receive `&["a", "b"].iter()` instead you'll have to type `&["a", "b"].iter().map(|&x| x)` (A similar thing happens with `&[String]`).

r? @aturon 

Full disclaimer: I haven't run `make`/`make check` yet (All my cores are busy)
2014-11-24 11:56:34 +00:00
bors
c637cab853 auto merge of #19223 : reem/rust/any-typeid-unstable, r=aturon
It is likely going to be removed and replaced
with an associated static.
2014-11-24 02:56:35 +00:00