about summary refs log tree commit diff
path: root/src/libcore/option.rs
AgeCommit message (Collapse)AuthorLines
2018-05-22Add Option::as_pin_mutTaylor Cramer-0/+10
2018-05-15Add Option::xor methodClar Charr-0/+36
2018-04-05Remove uses of option_filter featureThayne McCombs-2/+0
2018-04-01Stabilize `Option::filter`.Thayne McCombs-1/+1
Fixes #45860
2018-03-31Commit code for option size hintPhlosioneer-1/+6
2018-03-20Implement some trivial size_hints for various iteratorsPhlosioneer-0/+5
This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708.
2018-03-06Stabilize option_ref_mut_clonedMatt Brubeck-2/+1
Closes #43738.
2018-03-06Auto merge of #48768 - kennytm:rollup, r=kennytmbors-3/+3
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-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-3/+3
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-3/+3
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-02-26Fix doctest failurePhlosioneer-1/+0
Tried to be fancy with print statements.
2018-02-25Change the example string to something arbitraryPhlosioneer-4/+5
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-24Slight modification to the as_ref example of std::option::OptionPhlosioneer-2/+2
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-01-20Rollup merge of #47193 - cramertj:result-opts, r=TimNNGuillaume Gomez-0/+29
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-16Remove incorrect `Default::default` links, add a new oneGeoffry Song-7/+4
`map_or` and `map_or_else` don't use `Default::default`, but `unwrap_or_default` does.
2018-01-10Add transpose conversions for Option and ResultTaylor Cramer-0/+29
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.
2017-12-07Rollup merge of #46548 - jonathanstrong:master, r=dtolnayGuillaume Gomez-0/+17
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-07adds links to methods, removes trailing whitespaceJonathan Strong-5/+10
2017-12-06Adds language to the documentation for `Option` and `Result` suggestingJonathan Strong-0/+12
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-11-11Refactor Option::filter methodShanavas M-8/+4
2017-11-08Add `Option::filter()` according to RFC 2124Lukas Kalbertodt-0/+39
2017-09-27Rename option::Missing to NoneErrorHunter Praska-6/+9
2017-09-27Add docs for Missing, correct Option's Try testHunter Praska-1/+1
2017-09-27Impl Try for OptionHunter Praska-1/+24
2017-08-29Rollup merge of #43705 - panicbit:option_ref_mut_cloned, r=aturonAriel Ben-Yehuda-0/+20
libcore: Implement cloned() for Option<&mut T> None
2017-08-08Assign tracking issue to option_ref_mut_clonedpanicbit-1/+1
2017-08-07Fix Option<&mut T>::cloned doc testpanicbit-0/+1
2017-08-07libcore: Implement cloned() for Option<&mut T>panicbit-0/+19
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-1/+1
2017-07-25std: Stabilize `option_entry` featureAlex Crichton-6/+2
Stabilized: * `Option::get_or_insert` * `Option::get_or_insert_with` Closes #39288
2017-05-22Adding links to option::Optionprojektir-26/+60
2017-05-04Simplify types in `std::option` doc comment example.Corey Farwell-6/+6
2017-04-02Minor changes to core::option docsIrfan Hudda-6/+6
2017-04-01Improve docs of core::option::IterIrfan Hudda-1/+7
2017-04-01Improve docs of core::option::IterMutIrfan Hudda-1/+7
2017-04-01Improve docs of core::option::IntoIterIrfan Hudda-1/+7
2017-03-20Add missing urls in Option enumGuillaume Gomez-4/+13
2017-02-05Rollup merge of #39289 - shahn:option_entry, r=alexcrichtonCorey Farwell-0/+70
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-05Provide Entry-like API for OptionSebastian Hahn-0/+70
This implements #39288. Thanks to @steveklabnik and @oli-obk for their review comments :)
2017-01-30doc: minor Option improvementsTshepang Lekhonkhobe-3/+3
2016-11-30Add cloned example for OptionGuillaume Gomez-0/+10
2016-11-04Auto merge of #37306 - bluss:trusted-len, r=alexcrichtonbors-1/+10
Add Iterator trait TrustedLen to enable better FromIterator / Extend This trait attempts to improve FromIterator / Extend code by enabling it to trust the iterator to produce an exact number of elements, which means that reallocation needs to happen only once and is moved out of the loop. `TrustedLen` differs from `ExactSizeIterator` in that it attempts to include _more_ iterators by allowing for the case that the iterator's len does not fit in `usize`. Consumers must check for this case (for example they could panic, since they can't allocate a collection of that size). For example, chain can be TrustedLen and all numerical ranges can be TrustedLen. All they need to do is to report an exact size if it fits in `usize`, and `None` as the upper bound otherwise. The trait describes its contract like this: ``` An iterator that reports an accurate length using size_hint. The iterator reports a size hint where it is either exact (lower bound is equal to upper bound), or the upper bound is `None`. The upper bound must only be `None` if the actual iterator length is larger than `usize::MAX`. The iterator must produce exactly the number of elements it reported. This trait must only be implemented when the contract is upheld. Consumers of this trait must inspect `.size_hint()`’s upper bound. ``` Fixes #37232
2016-11-04Link the tracking issue for TrustedLenUlrik Sverdrup-3/+3
2016-10-31Changed most vec! invocations to use square bracesiirelu-2/+2
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-20Implement TrustedLen for more iteratorsUlrik Sverdrup-1/+10
2016-09-19fixed the safety header/wording in option.rsjacobpadkins-6/+4
2016-09-14Rollup merge of #36396 - athulappadan:Default-docs, r=blussGuillaume Gomez-0/+1
Documentation of what Default does for each type Addresses #36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
2016-09-11Documentation for default types modifiedathulappadan-1/+1
2016-09-11Documentation of what does for each typeathulappadan-0/+1
2016-09-11Improve Option docggomez-28/+50