Commit Graph

373 Commits

Author SHA1 Message Date
Brad Gibson
56016cb1e0 resolved upstream merge conflicts 2018-07-29 22:13:12 -07:00
kennytm
21f7d2b674
Rollup merge of #52218 - rivertam:patch-1, r=withoutboats
Amend option.take examples

It wasn't abundantly clear to me what `.take` returned. Perhaps this is a slightly frivolous change, but I think it's an improvement. =)

Apologies if I'm not following proper procedures.
2018-07-18 22:34:56 +08:00
Ben Berman
ede1a5d5ed
Amend option.take examples
It wasn't abundantly clear to me what `.take` returned. Perhaps this is a slightly frivolous change, but I think it's an improvement. =)

Apologies if I'm not following proper procedures.
2018-07-10 13:26:44 -04:00
Clément RENAULT
c8f0e6f210
Fix the documentation of Option::replace 2018-07-09 14:52:32 +02:00
Kerollmops
6035534586
Implement Option::replace in the core library 2018-07-04 21:54:45 +02:00
Pietro Albini
b71f6df5dd
Rollup merge of #51730 - MajorBreakfast:pin-get-mut-unchecked, r=withoutboats
New safe associated functions for PinMut

- Add safe `get_mut` and `map`
- Rename unsafe equivalents to `get_mut_unchecked` and `map_unchecked`

The discussion about this starts [in this comment](https://github.com/rust-lang/rust/issues/49150#issuecomment-399604573) on the tracking issue.
2018-06-26 11:35:37 +02:00
Josef Reinhard Brandl
3bcb85ee65 PinMut: Add safe get_mut and rename unsafe fns to get_mut_unchecked and map_unchecked 2018-06-23 18:29:56 +02:00
Martin Glagla
11341e2b06 Replace unreachable! with unreachable_unchecked 2018-06-20 10:08:11 +02:00
Taylor Cramer
15d2f965d8 Add Option::as_pin_mut 2018-05-22 17:24:49 -07:00
Clar Charr
8ab2d15f67 Add Option::xor method 2018-05-15 12:49:31 -04:00
Brad Gibson
c025fdebba fixed some and added more tests 2018-04-30 13:56:52 -07:00
Brad Gibson
6c7ea4ca9b refactored to implement without trait 2018-04-26 20:02:32 -07:00
Brad Gibson
4c2e3144a9 added DerefOption and DerefResult + tests to std 2018-04-26 18:14:23 -07:00
Thayne McCombs
c7ac32a1c1 Remove uses of option_filter feature 2018-04-05 00:02:33 -06:00
Thayne McCombs
5152a6f285 Stabilize Option::filter.
Fixes #45860
2018-04-01 22:11:51 -06:00
Phlosioneer
5057e3c9e1 Commit code for option size hint 2018-03-31 01:13:02 -04:00
Phlosioneer
619003d1d4 Implement some trivial size_hints for various iterators
This also implements ExactSizeIterator where applicable.

Addresses most of the Iterator traits mentioned in #23708.
2018-03-20 05:33:59 -04:00
Matt Brubeck
d04362f23d Stabilize option_ref_mut_cloned
Closes #43738.
2018-03-06 14:40:26 -08:00
bors
2789b067da Auto merge of #48768 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

- Successful merges: #48403, #48432, #48546, #48573, #48590, #48657, #48727, #48732, #48753, #48754, #48761, #48474, #48507, #47463
- Failed merges:
2018-03-06 15:01:21 +00:00
Ulrik Sverdrup
c7c23fe948 core: Update stability attributes for FusedIterator 2018-03-03 14:23:05 +01:00
Ulrik Sverdrup
bc651cac8d core: Stabilize FusedIterator
FusedIterator is a marker trait that promises that the implementing
iterator continues to return `None` from `.next()` once it has returned
`None` once (and/or `.next_back()`, if implemented).

The effects of FusedIterator are already widely available through
`.fuse()`, but with stable `FusedIterator`, stable Rust users can
implement this trait for their iterators when appropriate.
2018-03-03 14:14:03 +01:00
Phlosioneer
b7b3498ce8 Fix doctest failure
Tried to be fancy with print statements.
2018-02-26 19:48:15 -05:00
Phlosioneer
e8904f935a Change the example string to something arbitrary
The choice of string is arbitrary, so all references to a number
in the string were removed. The string is now the standard "Hello
world!".
2018-02-25 15:46:17 -05:00
Phlosioneer
bbd64b2563 Slight modification to the as_ref example of std::option::Option
A user in a reddit thread was confused by the name of the variable
"num_as_int"; they thought the example was trying to convert the
string "10" as if it were binary 2 by calling str::len(). In reality,
the example is simply demonstrating how to take an immutable reference
to the value of an Option. The confusion comes from the coincidence
that the length of the string "10" is also its binary representation,
and the implication from the variable names that a conversion was
occuring ("num_as_str" to "num_as_int").

This PR changes the example number to 12 instead of 10, and changes
the variable name from "num_as_int" to "num_length" to better
communicate what the example is doing.

The reddit thread:
https://www.reddit.com/r/rust/comments/7zpvev/notyetawesome_rust_what_use_cases_would_you_like/dur39xw/
2018-02-24 11:37:38 -05:00
Guillaume Gomez
0e270fc842 Rollup merge of #47193 - cramertj:result-opts, r=TimNN
Add transpose conversions for nested Option and Result

These impls are useful when working with combinator
methods that expect an option or a result, but you
have a `Result<Option<T>, E>` instead of an `Option<Result<T, E>>`
or vice versa.
2018-01-20 22:32:42 +01:00
Geoffry Song
46c20c0990
Remove incorrect Default::default links, add a new one
`map_or` and `map_or_else` don't use `Default::default`, but `unwrap_or_default` does.
2018-01-16 11:43:57 -08:00
Taylor Cramer
c9ae249265 Add transpose conversions for Option and Result
These impls are useful when working with combinator
methods that expect an option or a result, but you
have a Result<Option<T>, E> instead of an Option<Result<T, E>>
or vice versa.
2018-01-10 17:42:47 -08:00
Guillaume Gomez
0b47f02267 Rollup merge of #46548 - jonathanstrong:master, r=dtolnay
Recommends lazily evaluated alternatives for `Option::or` and `Result::or`

Adds language to docs for `Option` and `Result` recommending the use of lazily evaluated alternatives when appropriate. These comments are intended to echo a [clippy lint] on the same topic. The [reddit discussion] may also be of interest.

[clippy lint]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#or_fun_call
[reddit discussion]: https://www.reddit.com/r/rust/comments/7hutqn/perils_of_optionor_and_resultor/
2017-12-07 23:59:04 +01:00
Jonathan Strong
5847d0babd adds links to methods, removes trailing whitespace 2017-12-07 12:19:24 -05:00
Jonathan Strong
9307917d6a Adds language to the documentation for Option and Result suggesting
the use of lazily evaluated alternatives when appropriate. These
comments are intended to echo a clippy lint on the same topic (see
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#or_fun_call)
2017-12-06 20:30:57 -05:00
Shanavas M
abff092f90 Refactor Option::filter method 2017-11-11 17:32:29 +03:00
Lukas Kalbertodt
e65214441d Add Option::filter() according to RFC 2124 2017-11-08 10:23:12 +01:00
Hunter Praska
28996db803 Rename option::Missing to NoneError 2017-09-27 17:57:07 -04:00
Hunter Praska
8f63e8de46 Add docs for Missing, correct Option's Try test 2017-09-27 17:56:54 -04:00
Hunter Praska
2bd104fd4f Impl Try for Option 2017-09-27 17:56:15 -04:00
Ariel Ben-Yehuda
11e75fd115 Rollup merge of #43705 - panicbit:option_ref_mut_cloned, r=aturon
libcore: Implement cloned() for Option<&mut T>

None
2017-08-29 21:40:53 +00:00
panicbit
96182997da Assign tracking issue to option_ref_mut_cloned 2017-08-08 15:33:58 +02:00
panicbit
5383205555 Fix Option<&mut T>::cloned doc test 2017-08-07 12:55:03 +02:00
panicbit
51b29d618a libcore: Implement cloned() for Option<&mut T> 2017-08-07 02:24:35 +02:00
Isaac van Bakel
400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
Alex Crichton
64c1b23374 std: Stabilize option_entry feature
Stabilized:

* `Option::get_or_insert`
* `Option::get_or_insert_with`

Closes #39288
2017-07-25 07:09:31 -07:00
projektir
6e27bd8c01 Adding links to option::Option 2017-05-22 21:59:42 -04:00
Corey Farwell
7b94d6cf19 Simplify types in std::option doc comment example. 2017-05-04 11:53:24 -04:00
Irfan Hudda
4c9f8ae4fd Minor changes to core::option docs 2017-04-02 06:10:34 +05:30
Irfan Hudda
c414628782 Improve docs of core::option::Iter 2017-04-01 22:17:48 +05:30
Irfan Hudda
029ace4071 Improve docs of core::option::IterMut 2017-04-01 22:09:10 +05:30
Irfan Hudda
128a313ee2 Improve docs of core::option::IntoIter 2017-04-01 21:58:30 +05:30
Guillaume Gomez
17a26ee275 Add missing urls in Option enum 2017-03-20 15:09:02 +01:00
Corey Farwell
76e9ea7382 Rollup merge of #39289 - shahn:option_entry, r=alexcrichton
Provide Entry-like API for Option

This implements #39288.

I am wondering whether to use std::intrinsics::unreachable!() here. Both seems fine to me (the second match optimizes away in release mode).
2017-02-05 09:14:42 -05:00
Sebastian Hahn
8e02ad0ada Provide Entry-like API for Option
This implements #39288.

Thanks to @steveklabnik and @oli-obk for their review comments :)
2017-02-05 00:48:44 +01:00