summary refs log tree commit diff
path: root/src/libcore/option.rs
AgeCommit message (Collapse)AuthorLines
2014-10-07Reinstate AsSlice impls for Option and ResultNick Cameron-0/+16
2014-10-07Rename slice::SliceNick Cameron-16/+0
2014-09-28Defailbloat fail!(&'static str)Tobba-1/+1
2014-09-26Add Option::{ok_or, ok_or_else}Steven Fackler-1/+44
These are the inverses of `Result::ok` and help to bridge `Option` and `Result` based APIs.
2014-09-17doc: Backticks and spelling mistakes.Jonas Hietala-1/+1
2014-09-17doc: Methods for option::OptionJonas Hietala-1/+217
2014-09-16Align with _mut conventionsAaron Turon-2/+14
As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change]
2014-08-28Fallout from stabilizing core::optionAaron Turon-2/+2
2014-08-28stabilize core::optionAaron Turon-43/+104
Per API meeting https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md Most of the module is marked as stable or unstable; most of the unstable items are awaiting resolution of conventions issues. However, a few methods have been deprecated, either due to lack of use or redundancy: * `take_unwrap`, `get_ref` and `get_mut_ref` (redundant, and we prefer for this functionality to go through an explicit .unwrap) * `filtered` and `while` * `mutate` and `mutate_or_set` * `collect`: this functionality is being moved to a new `FromIterator` impl. Due to deprecations, this is a: [breaking-change]
2014-08-26Rebasing changesNick Cameron-1/+4
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-2/+8
2014-08-18Improve text of Option.unwrap()Steve Klabnik-1/+1
Fixes #9099
2014-08-13std: Rename slice::Vector to SliceBrian Anderson-2/+2
This required some contortions because importing both raw::Slice and slice::Slice makes rustc crash. Since `Slice` is in the prelude, this renaming is unlikely to casue breakage. [breaking-change]
2014-07-31Implement slice::Vector for Option<T> and CVec<T>Derek Harland-9/+12
2014-07-24librustc: Stop desugaring `for` expressions and translate them directly.Patrick Walton-1/+6
This makes edge cases in which the `Iterator` trait was not in scope and/or `Option` or its variants were not in scope work properly. This breaks code that looks like: struct MyStruct { ... } impl MyStruct { fn next(&mut self) -> Option<int> { ... } } for x in MyStruct { ... } { ... } Change ad-hoc `next` methods like the above to implementations of the `Iterator` trait. For example: impl Iterator<int> for MyStruct { fn next(&mut self) -> Option<int> { ... } } Closes #15392. [breaking-change]
2014-06-30auto merge of #15256 : erickt/rust/optimizations, r=alexcrichtonbors-10/+22
The bug #11084 causes `option::collect` and `result::collect` about twice as slower as it should because llvm is having some trouble optimizing away the scan closure. This gets rid of it so now those functions perform equivalent to a hand written version. This also adds an impl of `Default` for `Rc` along the way.
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-288/+0
Libcore's test infrastructure is complicated by the fact that many lang items are defined in the crate. The current approach (realcore/realstd imports) is hacky and hard to work with (tests inside of core::cmp haven't been run for months!). Moving tests to a separate crate does mean that they can only test the public API of libcore, but I don't feel that that is too much of an issue. The only tests that I had to get rid of were some checking the various numeric formatters, but those are also exercised through normal format! calls in other tests.
2014-06-29core: optimize {option,result}::collectErick Tryzelaar-10/+22
The bug #11084 causes these collect functions to run about twice as slow as they should because llvm is having trouble optimizing away the closure for some reason. This patch works around that performance bug by using a simple adapter iterator explicitly for capturing if the outer iterator returns an error.
2014-06-29librustc: Remove the fallback to `int` for integers and `f64` forPatrick Walton-2/+2
floating point numbers for real. This will break code that looks like: let mut x = 0; while ... { x += 1; } println!("{}", x); Change that code to: let mut x = 0i; while ... { x += 1; } println!("{}", x); Closes #15201. [breaking-change]
2014-06-28Rename all raw pointers as necessaryAlex Crichton-2/+2
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-20/+20
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-17change ~[] -> Vec for collect()Nathan Typanski-7/+11
This updates the documentation for result::collect() and option::collect() to use the new-style syntax for vectors, instead of the old ~[]. Also updates the code blocks for these docs so they will be tested automatically. closes #14991
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-2/+2
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-03std: Remove generics from Option::expectAlex Crichton-0/+14
This commit removes the <M: Any + Send> type parameter from Option::expect in favor of just taking a hard-coded `&str` argument. This allows this function to move into libcore. Previous code using strings with `expect` will continue to work, but code using this implicitly to transmit task failure will need to unwrap manually with a `match` statement. [breaking-change] Closes #14008
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-2/+2
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-2/+2
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-27std: Rename strbuf operations to stringRicho Healey-4/+4
[breaking-change]
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-7/+7
[breaking-change]
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-11/+13
[breaking-change]
2014-05-15core: Update all tests for fmt movementAlex Crichton-9/+16
2014-05-15core: Derive Show impls wherever possibleAlex Crichton-1/+1
These were temporarily moved to explicit implementations, but now that fmt is in core it's possible to derive again.
2014-05-12Improved example code in OptionAdolfo Ochagavía-12/+15
2014-05-11core: Remove the cast moduleAlex Crichton-2/+2
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-08Handle fallout in iter, option, result, and sync::arcKevin Ballard-9/+9
API changes: - UnsafeArc::newN() returns Vec<UnsafeArc<T>>
2014-05-07core: Move Option::expect to libstd from libcoreAlex Crichton-24/+0
See #14008 for more details
2014-05-07core: Get coretest workingAlex Crichton-4/+15
This mostly involved frobbing imports between realstd, realcore, and the core being test. Some of the imports are a little counterintuitive, but it mainly focuses around libcore's types not implementing Show while libstd's types implement Show.
2014-05-07core: Remove generics from Option::expectAlex Crichton-3/+1
The prospects of a generic failure function such as this existing in libcore are bleak, due to monomorphization not working across the crate boundary, and allocation into a ~Any is not allowed in libcore. The argument to expect() is now &str instead of <M: Send + Any> [breaking-change]
2014-05-07core: Inherit the option moduleAlex Crichton-0/+881
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-468/+0
This only changes the directory names; it does not change the "real" metadata names.
2013-05-19Register snapshotsBrian Anderson-18/+0
2013-05-19Use assert_eq! rather than assert! where possibleCorey Richardson-7/+7
2013-05-18Use four-space indentation, add trailing commas, and remove unnecessary uses ↵Brendan Zabarauskas-2/+2
of the return keyword
2013-05-18Convert various inner doc-comments to outer doc-commentsBrendan Zabarauskas-11/+5
2013-05-15rc: fix testsDaniel Micay-0/+10
2013-05-14Use static string with fail!() and remove fail!(fmt!())Björn Steinbrink-5/+5
fail!() used to require owned strings but can handle static strings now. Also, it can pass its arguments to fmt!() on its own, no need for the caller to call fmt!() itself.
2013-05-13Remove re-exports from libcore/core.rcAlex Crichton-0/+1
Also fix up all the fallout elsewhere throughout core. It's really nice being able to have the prelude.
2013-05-10core: Use the new `for` protocolAlex Crichton-0/+18
2013-05-04Register snapshotsBrian Anderson-104/+0
2013-05-02Remove 'Local Variable' commentsBrendan Zabarauskas-8/+0
2013-04-29test: Fix tests.Patrick Walton-2/+2