about summary refs log tree commit diff
path: root/src/libcore/option.rs
AgeCommit message (Collapse)AuthorLines
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
2013-04-29librustc: Remove `ptr::addr_of`.Patrick Walton-7/+8
2013-04-28make way for a new iter moduleDaniel Micay-9/+9
2013-04-10core: changes in response to #5656Niko Matsakis-0/+104
2013-04-05Refactor so that references to traits are not represented using a type with aNiko Matsakis-1/+27
bare function store (which is not in fact a kind of value) but rather ty::TraitRef. Removes many uses of fail!() and other telltale signs of type-semantic mismatch. cc #4183 (not a fix, but related)
2013-03-29librustc: Remove `fail_unless!`Patrick Walton-8/+8
2013-03-26option: rm functions that duplicate methodsDaniel Micay-243/+104
2013-03-23core: derive Clone for core typesAndrew Paseltiner-1/+1
2013-03-22libcore: Remove `pure` from libcore. rs=depurePatrick Walton-38/+38
2013-03-22core: replace uses of old deriving attribute with new oneAndrew Paseltiner-1/+1
2013-03-21librustc: Forbid destructors from being attached to any structs that might ↵Patrick Walton-0/+1
contain non-Owned fields. r=nmatsakis
2013-03-18librustc: Make the compiler ignore purity.Patrick Walton-4/+4
For bootstrapping purposes, this commit does not remove all uses of the keyword "pure" -- doing so would cause the compiler to no longer bootstrap due to some syntax extensions ("deriving" in particular). Instead, it makes the compiler ignore "pure". Post-snapshot, we can remove "pure" from the language. There are quite a few (~100) borrow check errors that were essentially all the result of mutable fields or partial borrows of `@mut`. Per discussions with Niko I think we want to allow partial borrows of `@mut` but detect obvious footguns. We should also improve the error message when `@mut` is erroneously reborrowed.
2013-03-18librustc: Convert all uses of old lifetime notation to new lifetime ↵Patrick Walton-10/+10
notation. rs=delifetiming
2013-03-14MutableIter impl for Option + use it in treemapDaniel Micay-1/+8
2013-03-12auto merge of #5328 : bstrie/rust/optadd, r=graydonbors-0/+13
This will allow you to use the `+` operator to add together any two Options, assuming that the contents of each Option likewise implement `+`. So Some(4) + Some(1) == Some(5), and adding with None leaves the other value unchanged. This might be monoidic? I don't know what that word means!
2013-03-11Implement Add on Option typesBen Striegel-0/+13
This will allow you to use the + operator to add together any two Options, assuming that the contents of each Option likewise implement +. So Some(4) + Some(1) == Some(5), and adding with None leaves the other value unchanged. This might be monoidic? I don't know what that word means!