about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-05-01auto merge of #13789 : sfackler/rust/debug-assert, r=pcwaltonbors-16/+59
I switched the `assert!` calls in `RefCell` over to `debug_assert!`. There are probably other instances that should be converted as well, but I couldn't think of any off the top of my head. RFC: 0015-assert
2014-05-01auto merge of #13886 : japaric/rust/fix-an-typos, r=alexcrichtonbors-2/+2
Found the first one in the rust reference docs. I was going to submit a PR with one fix, but figured I could look for more... This is the result.
2014-05-01Remove useless assert! caseSteven Fackler-5/+0
2014-05-01Add debug_assert and debug_assert_eq macrosSteven Fackler-11/+59
I also switched some `assert!` calls over to `debug_assert!`. Closes #12049. RFC: 0015-assert
2014-05-01Fix a/an typosJorge Aparicio-2/+2
2014-05-01auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichtonbors-17/+17
2014-05-01remove leftover obsolete string literalsDaniel Micay-17/+17
2014-04-30auto merge of #13648 : gereeter/rust/removed-rev, r=alexcrichtonbors-162/+155
In the process, `Splits` got changed to be more like `CharSplits` in `str` to present the DEI interface. Note that `treemap` still has a `rev_iter` function because it seems like it would be a significant interface change to expose a DEI - the iterator would have to gain an extra pointer, the completion checks would be more complicated, and it isn't easy to check that such an implementation is correct due to the use of unsafety to subvert the aliasing properties of `&mut`. This fixes #9391.
2014-04-30auto merge of #13864 : adrientetar/rust/fix-it-some-more, r=alexcrichtonbors-1/+1
Two selector fixes for rustdoc: - links colored in blue (#13807) was also affecting headers, which are anchored to their respective ids - the header unstyling from #13776 was being applied to all headers also Additionally, remove a stray title in the documentation. This makes the crate title of prelude appear as header instead of an inline paragraph of text (all others work normally and do not have that header tag). The design is unchanged from my previous template (e.g. [here](http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm)), however it is now properly applied. The last fix remaining is to enable webfonts service from `static.rust-lang.org`, this is #13593. r? @alexcrichton, @brson
2014-04-30auto merge of #13072 : bjz/rust/bitset, r=alexcrichtonbors-0/+260
The `bitflags!` macro generates a `struct` that holds a set of C-style bitmask flags. It is useful for creating typesafe wrappers for C APIs. For example: ~~~rust #[feature(phase)]; #[phase(syntax)] extern crate collections; bitflags!(Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100, FlagABC = FlagA.bits | FlagB.bits | FlagC.bits }) fn main() { let e1 = FlagA | FlagC; let e2 = FlagB | FlagC; assert!((e1 | e2) == FlagABC); // union assert!((e1 & e2) == FlagC); // intersection assert!((e1 - e2) == FlagA); // set difference } ~~~
2014-04-30Update for language changesBrendan Zabarauskas-1/+1
2014-04-30Move bitflags module to libstdBrendan Zabarauskas-0/+260
This will allow us to provide type-safe APIs in libstd that are C-compatible.
2014-04-30rustdoc: fix overly broad selectorsAdrien Tétar-1/+1
2014-04-29auto merge of #13857 : alexcrichton/rust/add-dylib-paths, r=brsonbors-2/+19
When a syntax extension is loaded by the compiler, the dylib that is opened may have other dylibs that it depends on. The dynamic linker must be able to find these libraries on the system or else the library will fail to load. Currently, unix gets by with the use of rpaths. This relies on the dylib not moving around too drastically relative to its dependencies. For windows, however, this is no rpath available, and in theory unix should work without rpaths as well. This modifies the compiler to add all -L search directories to the dynamic linker's set of load paths. This is currently managed through environment variables for each platform. Closes #13848
2014-04-29rustc: Add search paths to dylib load pathsAlex Crichton-2/+19
When a syntax extension is loaded by the compiler, the dylib that is opened may have other dylibs that it depends on. The dynamic linker must be able to find these libraries on the system or else the library will fail to load. Currently, unix gets by with the use of rpaths. This relies on the dylib not moving around too drastically relative to its dependencies. For windows, however, this is no rpath available, and in theory unix should work without rpaths as well. This modifies the compiler to add all -L search directories to the dynamic linker's set of load paths. This is currently managed through environment variables for each platform. Closes #13848
2014-04-29auto merge of #13772 : brson/rust/cratedocs, r=alexcrichtonbors-36/+106
Also move prelude explanation to the prelude module. This tries to provide a guide to what's in the standard library, organized bottom up from primitives to I/O.
2014-04-28Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is ↵Jonathan S-78/+91
provided (everywhere but treemap) This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also deprecates related functions like rsplit, rev_components, and rev_str_components. In every case, these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this more concrete, a translation table for all functional changes necessary follows: * container.rev_iter() -> container.iter().rev() * container.mut_rev_iter() -> container.mut_iter().rev() * container.move_rev_iter() -> container.move_iter().rev() * sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev() * path.rev_components() -> path.components().rev() * path.rev_str_components() -> path.str_components().rev() In terms of the type system, this change also deprecates any specialized reversed iterator types (except in treemap), opting instead to use Rev directly if any type annotations are needed. However, since methods directly returning reversed iterators are now discouraged, the need for such annotations should be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in the original reversed name and surround it with Rev<>: * RevComponents<'a> -> Rev<Components<'a>> * RevStrComponents<'a> -> Rev<StrComponents<'a>> * RevItems<'a, T> -> Rev<Items<'a, T>> * etc. The reasoning behind this change is that it makes the standard API much simpler without reducing readability, performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries (all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft goes away. [breaking-change]
2014-04-28Provide an implementation of DoubleEndedIterator for the results of ↵Jonathan S-84/+64
&[T]::split and &[T]::rsplit This makes the splitting functions in std::slice return DoubleEndedIterators. Unfortunately, splitn and rsplitn cannot provide such an interface and so must return different types. As a result, the following changes were made: * RevSplits was removed in favor of explicitly using Rev * Splits can no longer bound the number of splits done * Splits now implements DoubleEndedIterator * SplitsN was added, taking the role of what both Splits and RevSplits used to be * rsplit returns Rev<Splits<'a, T>> instead of RevSplits<'a, T> * splitn returns SplitsN<'a, T> instead of Splits<'a, T> * rsplitn returns SplitsN<'a, T> instead of RevSplits<'a, T> All functions that were previously implemented on each return value still are, so outside of changing of type annotations, existing code should work out of the box. In the rare case that code relied on the return types of split and splitn or of rsplit and rsplitn being the same, the previous behavior can be emulated by calling splitn or rsplitn with a bount of uint::MAX. The value of this change comes in multiple parts: * Consistency. The splitting code in std::str is structured similarly to the new slice splitting code, having separate CharSplits and CharSplitsN types. * Smaller API. Although this commit doesn't implement it, using a DoubleEndedIterator for splitting means that rsplit, path::RevComponents, path::RevStrComponents, Path::rev_components, and Path::rev_str_components are no longer needed - they can be emulated simply with .rev(). * Power. DoubleEndedIterators are able to traverse the list from both sides at once instead of only forwards or backwards. * Efficiency. For the common case of using split instead of splitn, the iterator is slightly smaller and slightly faster. [breaking-change]
2014-04-28auto merge of #13812 : alxgnon/rust/master, r=alexcrichtonbors-14/+23
This is a quick fix for repeated documentation descriptions in certain modules. Following is a list of the faulty modules I found. I ran `pcregrep -r -M "<p>(.+)\n\1" doc` on the html documentation to help identify them. - [rustuv::uvio](http://static.rust-lang.org/doc/master/rustuv/uvio/index.html) - [rustuv::uvll](http://static.rust-lang.org/doc/master/rustuv/uvll/index.html) - [std::rt::backtrace](http://static.rust-lang.org/doc/master/std/rt/backtrace/index.html) - [std::rt::env](http://static.rust-lang.org/doc/master/std/rt/env/index.html) - [std::rt::global_heap](http://static.rust-lang.org/doc/master/std/rt/global_heap/index.html) - [std::rt::local_heap](http://static.rust-lang.org/doc/master/std/rt/local_heap/index.html) - [std::rt::rtio](http://static.rust-lang.org/doc/master/std/rt/rtio/index.html) - [std::rt::task](http://static.rust-lang.org/doc/master/std/rt/task/index.html) - [std::rt::thread](http://static.rust-lang.org/doc/master/std/rt/thread/index.html) - [std::rt::unwind](http://static.rust-lang.org/doc/master/std/rt/unwind/index.html) - [syntax::parse::classify](http://static.rust-lang.org/doc/master/syntax/parse/classify/index.html) - [syntax::parse::common](http://static.rust-lang.org/doc/master/syntax/parse/common/index.html) After a little testing, I discovered that moving the documentation inside (`//!`) instead of outside (`///`) modules fixed the immediate problem. I went through the trouble of moving the documentation, and with this commit there are no more repeated descriptions within those faulty modules. This does not fix the underlying problem though. We should look into why having the documentation outside instead of inside caused the descriptions to be repeated. I will create a separate issue with my findings on the subject if necessary. In the meantime, this simple fix should be enough.
2014-04-28auto merge of #13797 : lifthrasiir/rust/std-mem-replace-doc, r=alexcrichtonbors-0/+32
Inspired by @steveklabnik's [comment](http://www.reddit.com/r/rust/comments/240p9s/eli5_stdmemreplace/ch2gxw8), this PR adds the practical use cases to the documentation of `std::mem::replace`. Caveat: We need a `compile-fail` equivalent for doctest. :p
2014-04-28Fixed typo in std::vecAdolfo Ochagavía-1/+1
2014-04-28std: Add more docs to `std::mem::replace`.Kang Seonghoon-0/+32
2014-04-27Fix repeated module documentationAlexandre Gagnon-14/+23
2014-04-27std: Rewrite crate docsBrian Anderson-36/+106
Also move prelude explanation to the prelude module.
2014-04-27auto merge of #13799 : m-r-r/rust/patch-std-io-standard_error, r=alexcrichtonbors-1/+15
Hello, With the latest version of Rust, calling to the function [`std::io::standard_error()`](http://static.rust-lang.org/doc/master/std/io/fn.standard_error.html) succeeds only if the value of the argument is `EndOfFile`, `IoUnavailable` or `InvalidInput`. If the function is called with another value as argument, it fails without message. Here is a piece of code that reproduces the problem: ```rust use std::io::{standard_error,EndOfFile,FileNotFound,PermissionDenied}; fn main() { println!("Error 1: {}", standard_error(EndOfFile)); // does not fail println!("Error 2: {}", standard_error(FileNotFound)); // fails println!("Error 3: {}", standard_error(PermissionDenied)); //fails } ``` This was because the `IoErrorKind` passed as argument wasn't matched against all the possible values. I added the missing branches in the `match` statement inside the function, and i removed the call to the `fail!()` macro. I rebuilt the crate with the latest `rustc` version and it seems to works.
2014-04-27auto merge of #13792 : jacob-hegna/rust/master, r=alexcrichtonbors-10/+28
Just modified the documentation for parse_bytes to make it more clear how the bytes were parsed (big endian) and to show an example of what it returned. I also added documentation for the to_str_bytes which previously had no documentation (besides one stackoverflow post).
2014-04-27Rewrote documentation for parse_bytes and to_str_bytes in {int, uint}_macros.rsJacob Hegna-10/+28
2014-04-27Fixed typo in std::iterAdolfo Ochagavía-1/+1
2014-04-27Added missing values in std::io::standard_error()m-r-r-1/+15
2014-04-26Fixing permutation of small lists, such that [], [x] -> [[]], [[x]], and ↵Wendell Smith-7/+48
updating size_hints. Fixes #13734 and #13759.
2014-04-25clarify docs for std:io::fs::Path::{is_dir,is_file,exists}; add lstatAaron Turon-28/+28
Clarifies the interaction of `is_dir`, `is_file` and `exists` with symbolic links. Adds a convenience `lstat` function alongside of `stat`. Removes references to conditions. Closes issue #12583.
2014-04-25auto merge of #13735 : aturon/rust/float-consts-take-2, r=brsonbors-19/+40
Follow-up on issue #13297 and PR #13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
2014-04-24auto merge of #13697 : pongad/rust/consts, r=alexcrichtonbors-172/+130
I decided to put architecture constants in another mod. They are not used, so a part of me is thinking of just getting rid of them altogether. The rest should be similar to what @brson wants. Fixes #13536
2014-04-25Cleaned up os::consts. The module only exposes constants for the target OS ↵Michael Darakananda-172/+130
and arch. Constants for other OS's and arch's must be defined manually. [breaking-change]
2014-04-24auto merge of #13723 : alexcrichton/rust/pipe-connect-timeout, r=brsonbors-2/+93
This adds support for connecting to a unix socket with a timeout (a named pipe on windows), and accepting a connection with a timeout. The goal is to bring unix pipes/named sockets back in line with TCP support for timeouts. Similarly to the TCP sockets, all methods are marked #[experimental] due to uncertainty about the type of the timeout argument. This internally involved a good bit of refactoring to share as much code as possible between TCP servers and pipe servers, but the core implementation did not change drastically as part of this commit. cc #13523
2014-04-24auto merge of #13711 : alexcrichton/rust/snapshots, r=brsonbors-2/+0
These are the first successful snapshots after the LLVM upgrade, built with LLVM that requires C++11
2014-04-24add min_pos_value constant for floatsAaron Turon-19/+40
Follow-up on issue #13297 and PR #13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
2014-04-24std: Add timeouts to unix connect/acceptAlex Crichton-2/+93
This adds support for connecting to a unix socket with a timeout (a named pipe on windows), and accepting a connection with a timeout. The goal is to bring unix pipes/named sockets back in line with TCP support for timeouts. Similarly to the TCP sockets, all methods are marked #[experimental] due to uncertainty about the type of the timeout argument. This internally involved a good bit of refactoring to share as much code as possible between TCP servers and pipe servers, but the core implementation did not change drastically as part of this commit. cc #13523
2014-04-24auto merge of #13720 : aturon/rust/walk_dir-perf, r=alexcrichtonbors-2/+29
The `walk_dir` iterator was simulating a queue using a vector (in particular, using `shift`), leading to O(n^2) performance. Since the order was not well-specified (see issue #13411), the simplest fix is to use the vector as a stack (and thus yield a depth-first traversal). This patch does exactly that, and adds a test checking for depth-first behavior. Note that the underlying `readdir` function does not specify any particular order, nor does the system call it uses. Closes #13411.
2014-04-24fix O(n^2) perf bug for std::io::fs::walk_dirAaron Turon-2/+29
The `walk_dir` iterator was simulating a queue using a vector (in particular, using `shift`), leading to O(n^2) performance. Since the order was not well-specified (see issue #13411), the simplest fix is to use the vector as a stack (and thus yield a depth-first traversal). This patch does exactly that. It leaves the order as originally specified -- "some top-down order" -- and adds a test to ensure a top-down traversal. Note that the underlying `readdir` function does not specify any particular order, nor does the system call it uses. Closes #13411.
2014-04-24Update libuvAlex Crichton-2/+2
This update brings a few months of changes, but primarily a fix for the following situation. When creating a handle to stdin, libuv used to set the stdin handle to nonblocking mode. This would end up affect this stdin handle across all processes that shared it, which mean that stdin become nonblocking for everyone using the same stdin. On linux, this also affected *stdout* because stdin/stdout roughly point at the same thing. This problem became apparent when running the test suite manually on a local computer. The stdtest suite (running with libgreen) would set stdout to nonblocking mode (as described above), and then the next test suite would always fail for a printing failure (because stdout was returning EAGAIN). This has been fixed upstream, joyent/libuv@342e8c, and this update pulls in this fix. This also brings us in line with a recently upstreamed libuv patch. Closes #13336 Closes #13355
2014-04-24auto merge of #13710 : aturon/rust/float-constants, r=brsonbors-75/+94
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrect, even when the values were correct. Closes #13297. Closes #11537.
2014-04-23auto merge of #13675 : sfackler/rust/taskbuilder-new, r=alexcrichtonbors-34/+27
The constructor for `TaskBuilder` is being changed to an associated function called `new` for consistency with the rest of the standard library. Closes #13666 [breaking-change]
2014-04-23Move task::task() to TaskBuilder::new()Steven Fackler-34/+27
The constructor for `TaskBuilder` is being changed to an associated function called `new` for consistency with the rest of the standard library. Closes #13666 [breaking-change]
2014-04-23auto merge of #13688 : alexcrichton/rust/accept-timeout, r=brsonbors-1/+86
This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523
2014-04-23std: Add support for an accept() timeoutAlex Crichton-1/+86
This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523
2014-04-23Register new snapshotsAlex Crichton-2/+0
These are the first successful snapshots after the LLVM upgrade, built with LLVM that requires C++11
2014-04-23auto merge of #13705 : edwardw/rust/rcboxptr-doc, r=alexcrichtonbors-1/+1
It is for internal use only and should not appear in docs.
2014-04-23fix std::f32 and std::f64 constantsAaron Turon-75/+94
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrent, even when the values were correct. Closes #13297. Closes #11537.
2014-04-23auto merge of #13686 : alexcrichton/rust/issue-12224, r=nikomatsakisbors-95/+109
This alters the borrow checker's requirements on invoking closures from requiring an immutable borrow to requiring a unique immutable borrow. This means that it is illegal to invoke a closure through a `&` pointer because there is no guarantee that is not aliased. This does not mean that a closure is required to be in a mutable location, but rather a location which can be proven to be unique (often through a mutable pointer). For example, the following code is unsound and is no longer allowed: type Fn<'a> = ||:'a; fn call(f: |Fn|) { f(|| { f(|| {}) }); } fn main() { call(|a| { a(); }); } There is no replacement for this pattern. For all closures which are stored in structures, it was previously allowed to invoke the closure through `&self` but it now requires invocation through `&mut self`. The standard library has a good number of violations of this new rule, but the fixes will be separated into multiple breaking change commits. Closes #12224