about summary refs log tree commit diff
path: root/src/libcore/result.rs
AgeCommit message (Collapse)AuthorLines
2015-01-05Stabilization of impls and fallout from stabilizationAaron Turon-0/+9
2015-01-03sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rsJorge Aparicio-2/+2
2015-01-03sed -i -s 's/\bmod,/self,/g' **/*.rsJorge Aparicio-1/+1
2015-01-03core: use assoc types in Iterator et alJorge Aparicio-12/+20
2014-12-26Fixed minor typo in docs for `Result`'s `err` methodYawarRaza7349-1/+1
2014-12-21Fallout of std::str stabilizationAlex Crichton-1/+1
2014-12-19std: Second pass stabilization of Result<T, E>Alex Crichton-54/+90
This commit, like the second pass of `Option`, largely just stablizes the existing functionality after renaming a few iterators. The specific actions taken were: * The `Ok` and `Err` variants were marked `#[stable]` as the stability inheritance was since removed. * The `as_mut` method is now stable. * The `map` method is now stable * The `map_err` method is now stable * The `iter`, `iter_mut`, and `into_iter` methods now returned structures named after the method of iteration. The methods are also now all stable. * The `and_then` method is now stable. * The `or_else` method is now stable. * The `unwrap` family of functions are now all stable: `unwrap_or`, `unwrap_or_else`, `unwrap`, and `unwrap_err`. There is a possible open extension to `Result::{and, and_then}` to make the return type further generic over `FromError` (as proposed in #19078), but this is a backwards compatible change due to the usage of default type parameters, which makes the two functions safe to stabilize now regardless of the outcome of that issue.
2014-12-19libcore: use `#[deriving(Copy)]`Jorge Aparicio-5/+1
2014-12-18librustc: Always parse `macro!()`/`macro![]` as expressions if notPatrick Walton-1/+1
followed by a semicolon. This allows code like `vec![1i, 2, 3].len();` to work. This breaks code that uses macros as statements without putting semicolons after them, such as: fn main() { ... assert!(a == b) assert!(c == d) println(...); } It also breaks code that uses macros as items without semicolons: local_data_key!(foo) fn main() { println("hello world") } Add semicolons to fix this code. Those two examples can be fixed as follows: fn main() { ... assert!(a == b); assert!(c == d); println(...); } local_data_key!(foo); fn main() { println("hello world") } RFC #378. Closes #18635. [breaking-change]
2014-12-15Move hash module from collections to coreSteven Fackler-1/+1
2014-12-13libcore: use unboxed closures in `Result` methodsJorge Aparicio-6/+8
2014-12-11Register new snapshotsAlex Crichton-1/+0
2014-12-09rollup merge of #19653: frewsxcv/rm-reexportsAlex Crichton-1/+1
Brief note: This does *not* affect anything in the prelude Part of #19253 All this does is remove the reexporting of Result and Option from their respective modules. More core reexports might be removed, but these ones are the safest to remove since these enums (and their variants) are included in the prelude. Depends on https://github.com/rust-lang/rust/pull/19407 which is merged, but might need a new snapshot [breaking-change]
2014-12-08Remove Result and Option reexportsCorey Farwell-1/+1
Brief note: This does *not* affect anything in the prelude Part of #19253 All this does is remove the reexporting of Result and Option from their respective modules. More core reexports might be removed, but these ones are the safest to remove since these enums (and their variants) are included in the prelude. [breaking-change]
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+5
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-05Utilize fewer reexportsCorey Farwell-1/+2
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-04auto merge of #18980 : erickt/rust/reader, r=ericktbors-5/+4
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-04core: fix a doctestErick Tryzelaar-2/+2
2014-12-03Fix falloutJorge Aparicio-3/+3
2014-11-30std: add Reader impl for &[u8]Erick Tryzelaar-4/+3
2014-11-25Fallout from stabilizationAaron Turon-2/+2
2014-11-22Fix typo in Result documentationNicholas Bishop-1/+1
2014-11-19rollup merge of #18903: steveklabnik/error_handling_guideJakub Bukaj-46/+0
Now that we've done `fail` -> `panic`, I feel bringing back the error handling guide is a good idea. We had one long ago, but it was removed when conditions were removed. This doesn't cover the new FromError stuff, but I feel like it's already useful in this state, so I'm sending this PR now.
2014-11-18Error handling guideSteve Klabnik-46/+0
2014-11-17Switch to purely namespaced enumsSteven Fackler-2/+4
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17Fix fallout from coercion removalNick Cameron-3/+3
2014-11-16rollup merge of #18970: aturon/fixup-stableJakub Bukaj-1/+6
2014-11-14libs: fix #[stable] inheritance falloutAaron Turon-1/+6
A recent change turned off inheritance for the #[stable] by default, but failed to catch all the cases where this was being used in std. This patch fixes that problem.
2014-11-12Results aren't panicsArtem-1/+1
A typo about Results being panics crawled in. Fixing it.
2014-11-05Fix fallout of changing the expansion of `#[deriving(PartialEq)]`Jorge Aparicio-1/+0
2014-11-05Repair various cases where values of distinct types were being operatedNiko Matsakis-2/+2
upon (e.g., `&int` added to `int`).
2014-11-03core: Fix fallout of changing `#[deriving(Clone)]`Jorge Aparicio-1/+0
2014-10-29Rename fail! to panic!Steve Klabnik-23/+23
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-40/+0
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-07Reinstate AsSlice impls for Option and ResultNick Cameron-0/+21
2014-10-07Rename slice::SliceNick Cameron-21/+0
2014-09-17doc: Methods for result::Result.Jonas Hietala-28/+228
2014-09-17doc: Cleanup.Jonas Hietala-27/+27
Remove ~~~ for code block specification. Use /// Over /** */ for doc blocks.
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-28stabilize core::resultAaron Turon-41/+173
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. * `collect`: this functionality is being moved to a new `FromIterator` impl. * `fold_` is deprecated due to lack of use * Several methods found in `core::option` are added here, including `iter`, `as_slice`, and variants. Due to deprecations, this is a: [breaking-change]
2014-07-14Document that Result.unwrap prints the Err's valuemasklinn-2/+8
It is implied by the Show bound, but that implication can be missed.
2014-07-04Fixed Result type parameters in doc comment.Zbigniew Siciarz-1/+1
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-163/+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-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-13/+13
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-10Fix more misspelled comments and strings.Joseph Crail-1/+1
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-1/+1
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-06-01auto merge of #14580 : utkarshkukreti/rust/fix-docs-for-result-map, ↵bors-1/+3
r=alexcrichton `reader.read_line()` includes trailing newline char, which makes `from_str` always return `None`.