about summary refs log tree commit diff
path: root/src/libstd/option.rs
AgeCommit message (Collapse)AuthorLines
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-2/+2
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-05Implement clone() for TCP/UDP/Unix socketsAlex Crichton-1/+0
This is part of the overall strategy I would like to take when approaching issue #11165. The only two I/O objects that reasonably want to be "split" are the network stream objects. Everything else can be "split" by just creating another version. The initial idea I had was the literally split the object into a reader and a writer half, but that would just introduce lots of clutter with extra interfaces that were a little unnnecssary, or it would return a ~Reader and a ~Writer which means you couldn't access things like the remote peer name or local socket name. The solution I found to be nicer was to just clone the stream itself. The clone is just a clone of the handle, nothing fancy going on at the kernel level. Conceptually I found this very easy to wrap my head around (everything else supports clone()), and it solved the "split" problem at the same time. The cloning support is pretty specific per platform/lib combination: * native/win32 - uses some specific WSA apis to clone the SOCKET handle * native/unix - uses dup() to get another file descriptor * green/all - This is where things get interesting. When we support full clones of a handle, this implies that we're allowing simultaneous writes and reads to happen. It turns out that libuv doesn't support two simultaneous reads or writes of the same object. It does support *one* read and *one* write at the same time, however. Some extra infrastructure was added to just block concurrent writers/readers until the previous read/write operation was completed. I've added tests to the tcp/unix modules to make sure that this functionality is supported everywhere.
2014-02-04Replace NonCopyable usage with NoPodFlavio Percoco-1/+2
cc #10834
2014-02-03std: Remove io::io_errorAlex Crichton-1/+1
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02std: rename fmt::Default to `Show`.Huon Wilson-1/+1
This is a better name with which to have a #[deriving] mode. Decision in: https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
2014-01-31Fix minor doc typosVirgile Andreani-1/+1
2014-01-25Uppercase numeric constantsChris Wong-2/+2
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-21Remove unnecessary parentheses.Huon Wilson-2/+2
2014-01-18Rename iterators for consistencyPalmer Cox-12/+12
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-0/+19
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-11Remove re-exports of std::io::stdio::{print, println} in the prelude.Brendan Zabarauskas-1/+1
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
2014-01-09port over the old tests to the new `Rc`Daniel Micay-1/+1
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-0/+1
2014-01-08Renamed Option::map_default and mutate_default to map_or and mutate_or_setMarvin Löbel-4/+4
2013-12-29auto merge of #11134 : lucab/rust/lucab/libstd-doc, r=cmrbors-1/+1
Uniform the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index.
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-26std: result::collect to take an iterator, add option::collectErick Tryzelaar-1/+65
2013-12-21std: Remove some @-boxesBrian Anderson-6/+12
2013-12-19std::str: replace .as_imm_buf with .as_ptr.Huon Wilson-2/+2
2013-12-14Remove {As,Into,To}{Option,Either,Result} traits.Chris Morgan-122/+0
Expanded, that is: - `AsOption` - `IntoOption` - `ToOption` - `AsEither` - `IntoEither` - `ToEither` - `AsResult` - `IntoResult` - `ToResult` These were defined for each other but never *used* anywhere. They are all trivial and so removal will have negligible effect upon anyone. `Either` has fallen out of favour (and its implementation of these traits of dubious semantics), `Option<T>` → `Result<T, ()>` was never really useful and `Result<T, E>` → `Option<T>` should now be done with `Result.ok()` (mirrored with `Result.err()` for even more usefulness). In summary, there's really no point in any of these remaining.
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-2/+2
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-9/+9
2013-11-01Fixed unused import warning in testsMarvin Löbel-1/+1
2013-11-01Removed legacy implementationsMarvin Löbel-61/+0
2013-11-01Cleaned up the option and result module in more detailMarvin Löbel-36/+30
Made both types implement more standard traits in a nicer way Derived more traits
2013-11-01Reordered the methods in std::Option and std::ResultMarvin Löbel-167/+216
Cleaned up the source in a few places Renamed `map_move` to `map`, removed other `map` methods Added `as_ref` and `as_mut` adapters to `Result` Added `fmt::Default` impl
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-6/+6
Who doesn't like a massive renaming?
2013-10-09option: rewrite the API to use compositionDaniel Micay-59/+24
2013-10-02Check enums in missing_doc lintSteven Fackler-0/+1
Closes #9671
2013-09-30std: Remove usage of fmt!Alex Crichton-16/+18
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-2/+2
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g' find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g' find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-21Fix example in std::OptionGrigoriy-1/+1
2013-09-17std: Remove Option.or_{default,zero}Erick Tryzelaar-19/+1
These can be replaced with `Some(option.or_default())`.
2013-09-16switch Drop to `&mut self`Daniel Micay-1/+1
2013-09-12std: Restore Option::chain{,_mut}_ref as and_then{,_mut}_refErick Tryzelaar-4/+24
2013-09-12std: Remove Zero impl for OptionErick Tryzelaar-5/+0
Options are not numeric types, so it doesn't make sense for them to implement Zero.
2013-09-12std: Add a bunch of Default implsErick Tryzelaar-0/+1
2013-09-12std: Rename {Option,Result}::chain{,_err}* to {and_then,or_else}Erick Tryzelaar-36/+6
2013-09-12std: Add ToEither/IntoEither/AsEitherErick Tryzelaar-0/+42
2013-09-12std: Add ToResult/IntoResult/AsResultErick Tryzelaar-0/+41
2013-09-12std: Add ToOption/IntoOption/AsOptionErick Tryzelaar-0/+65
2013-09-12std: Add Option.{and,and_then,or,or_else}Erick Tryzelaar-8/+81
2013-09-12std: Add Option.unwrap_or_else and a couple testsErick Tryzelaar-0/+47
2013-09-12std: Add Option.{result_or_default,or_default} that uses DefaultErick Tryzelaar-0/+20
2013-09-12std: add default implementations to OptionErick Tryzelaar-0/+5
2013-09-12std: rename Option::unwrap_or_default() to unwrap_or()Erick Tryzelaar-1/+1
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-6/+6
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-09-01std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iteratorsblake2-ppc-1/+3
2013-08-27option: rm implementation of AddDaniel Micay-13/+0
Closes #6002 There is consensus that the current implementation should be changed or removed, so removing it seems like the right decision for now.