about summary refs log tree commit diff
path: root/src/libstd/option.rs
AgeCommit message (Collapse)AuthorLines
2014-06-03std: Remove generics from Option::expectAlex Crichton-170/+0
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-05-12Improved example code in OptionAdolfo Ochagavía-12/+15
2014-05-07Test fixes and rebase conflictsAlex Crichton-5/+5
2014-05-07core: Move Option::expect to libstd from libcoreAlex Crichton-0/+167
See #14008 for more details
2014-05-07core: Inherit the option moduleAlex Crichton-882/+0
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-5/+5
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-3/+3
2014-04-23Fix other bugs with new closure borrowingAlex Crichton-2/+2
This fixes various issues throughout the standard distribution and tests.
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-4/+4
2014-04-03std: Remove `RefCell::set()`Erick Tryzelaar-1/+1
2014-04-03std: Remove `RefCell::get()`Erick Tryzelaar-2/+3
It's surprising that `RefCell::get()` is implicitly doing a clone on a value. This patch removes it and replaces all users with either `.borrow()` when we can autoderef, or `.borrow().clone()` when we cannot.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-1/+1
2014-03-30Rename `from_iterator` to `from_iter` for consistency.Brian Anderson-1/+1
2014-03-28Rename Pod into CopyFlavio Percoco-1/+1
Summary: So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the Pod kind into Copy. RFC: 0003-opt-in-builtin-traits Test Plan: make check Reviewers: cmr Differential Revision: http://phabricator.octayn.net/D3
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-1/+1
value
2014-03-22rustc: Remove all usage of manual deref()Alex Crichton-2/+2
Favor using '*' instead
2014-03-20rename std::vec -> std::sliceDaniel Micay-4/+4
Closes #12702
2014-03-19auto merge of #12982 : brson/rust/optiondocs, r=alexcrichtonbors-20/+170
Various improvements. There's a lot more that can be done.
2014-03-18std: Improve option docsBrian Anderson-20/+170
2014-03-18Documentation and formatting changes for option.rs.Ziad Hatahet-10/+10
2014-03-16Refactored take_unwrap (libstd/option.rs)aochagavia-3/+3
Using pattern matching instead of is_some + unwrap
2014-03-14auto merge of #12888 : aochagavia/rust/Fix-comment, r=alexcrichtonbors-9/+3
The old comment of as_mut_slice() did not describe the function correctly. The new one does. Also refactored option::iter() and option::mut_iter() to use as_ref() and as_mut() instead of match.
2014-03-14Refactored iter and mut_iteraochagavia-8/+2
Replaced match by self.as_ref() and self.as_mut()
2014-03-14Fixed comment of as_mut_slice (libstd/option.rs)aochagavia-1/+1
The old comment did not describe the function correctly
2014-03-14auto merge of #12871 : aochagavia/rust/Optimize-while_some, r=alexcrichtonbors-3/+6
The old 'while' needed to match 2 times for each iteration. With the new 'loop' there is just one match needed. I have also replaced 'blk' by 'f' to be more consistent with parameter names in other functions that are implemented for Option<T>
2014-03-13Refactored while_some (libstd/option.rs)aochagavia-3/+6
The old 'while' needed to match 2 times for each iteration. With the new 'loop' there is just one match needed. I have also replaced 'blk' by 'f' to be more consistent with parameter names in other functions that are implemented for Option
2014-03-13Remove Rc's borrow method to avoid conflicts with RefCell's borrow in ↵Eduard Burtescu-2/+2
Rc<RefCell<T>>.
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-4/+3
2014-03-07create a sensible comparison trait hierarchyDaniel Micay-1/+1
* `Ord` inherits from `Eq` * `TotalOrd` inherits from `TotalEq` * `TotalOrd` inherits from `Ord` * `TotalEq` inherits from `Eq` This is a partial implementation of #12517.
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-14/+1
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
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