summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-11-06rollup merge of #18628 : aturon/fixup-error-commentAlex Crichton-3/+0
2014-11-06rollup merge of #18605 : Gankro/collect-fruitAlex Crichton-220/+231
2014-11-07Fixing #18659juxiliary-1/+17
Changes the radix multiplier to start at -0.0 instead of -1.0 when reading strings that start with '-'.
2014-11-06Fallout from collection conventionsAlexis Beingessner-3/+3
2014-11-06Implement low-hanging fruit of collection conventionsAlexis Beingessner-217/+228
* Renames/deprecates the simplest and most obvious methods * Adds FIXME(conventions)s for outstanding work * Marks "handled" methods as unstable NOTE: the semantics of reserve and reserve_exact have changed! Other methods have had their semantics changed as well, but in a way that should obviously not typecheck if used incorrectly. Lots of work and breakage to come, but this handles most of the core APIs and most eggregious breakage. Future changes should *mostly* focus on niche collections, APIs, or simply back-compat additions. [breaking-change]
2014-11-06Prelude: rename and consolidate extension traitsAaron Turon-54/+51
This commit renames a number of extension traits for slices and string slices, now that they have been refactored for DST. In many cases, multiple extension traits could now be consolidated. Further consolidation will be possible with generalized where clauses. The renamings are consistent with the [new `-Prelude` suffix](https://github.com/rust-lang/rfcs/pull/344). There are probably a few more candidates for being renamed this way, but that is left for API stabilization of the relevant modules. Because this renames traits, it is a: [breaking-change] However, I do not expect any code that currently uses the standard library to actually break. Closes #17917
2014-11-06Make Filetype ClonableSubhash Bhushan-1/+1
2014-11-06std::rand::OsRng: Use `getrandom` syscall on Linuxklutzy-12/+120
`getrandom(2)` system call [1] has been added on Linux 3.17. This patch makes `OsRng` use `getrandom` if available, and use traditional `/dev/urandom` fallback if not. [1]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c6e9d6f38894798696f23c8084ca7edbf16ee895
2014-11-05auto merge of #18486 : nikomatsakis/rust/operator-dispatch, r=pcwaltonbors-4/+4
This branch cleans up overloaded operator resolution so that it is strictly based on the traits in `ops`, rather than going through the normal method lookup mechanism. It also adds full support for autoderef to overloaded index (whereas before autoderef only worked for non-overloaded index) as well as for the slicing operators. This is a [breaking-change]: in the past, we were accepting combinations of operands that were not intended to be accepted. For example, it was possible to compare a fixed-length array and a slice, or apply the `!` operator to a `&int`. See the first two commits in this pull-request for examples. One downside of this change is that comparing fixed-length arrays doesn't always work as smoothly as it did before. Before this, comparisons sometimes worked due to various coercions to slices. I've added impls for `Eq`, `Ord`, etc for fixed-lengths arrays up to and including length 32, but if the array is longer than that you'll need to either newtype the array or convert to slices. Note that this plays better with deriving in any case than the previous scheme. Fixes #4920. Fixes #16821. Fixes #15757. cc @alexcrichton cc @aturon
2014-11-05Fix example in HashMap::new() docsCristi Burcă-1/+1
2014-11-05auto merge of #18462 : netvl/rust/to-socket-addr, r=alexcrichtonbors-250/+404
This is a follow-up to [RFC PR #173](https://github.com/rust-lang/rfcs/pull/173). I was told there that changes like this don't need to go through the RFC process, so I'm submitting this directly. This PR introduces `ToSocketAddr` trait as defined in said RFC. This trait defines a conversion from different types like `&str`, `(&str, u16)` or even `SocketAddr` to `SocketAddr`. Then this trait is used in all constructor methods for `TcpStream`, `TcpListener` and `UdpSocket`. This unifies these constructor methods - previously they were using different types of input parameters (TCP ones used `(&str, u16)` pair while UDP ones used `SocketAddr`), which is not consistent by itself and sometimes inconvenient - for example, when the address initially is available as `SocketAddr`, you still need to convert it to string to pass it to e.g. `TcpStream`. This is very prominently demonstrated by the unit tests for TCP functionality. This PR makes working with network objects much like with `Path`, which also uses similar trait to be able to be constructed from `&[u8]`, `Vec<u8>` and other `Path`s. This is a breaking change. If constant literals were used before, like this: ```rust TcpStream::connect("localhost", 12345) ``` then the nicest fix is to change it to this: ```rust TcpStream::connect("localhost:12345") ``` If variables were used before, like this: ```rust TcpStream::connect(some_address, some_port) ``` then the arguments should be wrapped in another set of parentheses: ```rust TcpStream::connect((some_address, some_port)) ``` `UdpSocket` usages won't break because its constructor method accepted `SocketAddr` which implements `ToSocketAddr`, so `bind()` calls: ```rust UdpSocket::bind(some_socket_addr) ``` will continue working as before. I haven't changed `UdpStream` constructor because it is deprecated anyway.
2014-11-05Fixed not compiling code in docstringVladimir Matveev-2/+2
2014-11-05Add impls of the comparison operators for fixed-length arrays of lengths ↵Niko Matsakis-1/+1
0...32 and repair various cases where slices and fixed-length arrays were being compared.
2014-11-05Repair various cases where values of distinct types were being operatedNiko Matsakis-3/+3
upon (e.g., `&int` added to `int`).
2014-11-05Register snapshots.Eduard Burtescu-16/+0
2014-11-05Added more documentation on ToSocketAddr traitVladimir Matveev-3/+92
2014-11-05Fixed tidy errorsVladimir Matveev-3/+3
2014-11-05Fixed other tests to pass make checkVladimir Matveev-8/+5
2014-11-05Migrated io::net::udp over to ToSocketAddrVladimir Matveev-20/+34
UdpSocket constructor methods now use ToSocketAddr trait instead of SocketAddr. [breaking-change]
2014-11-05Switched io::net::tcp to use ToSocketAddrVladimir Matveev-227/+130
TcpListener and TcpStream are converted to use ToSocketAddr trait in their constructor methods. [breaking-change]
2014-11-05Added ToSocketAddr traitVladimir Matveev-0/+151
This commit adds ToSocketAddr trait to std::io::net::ip module. This trait is used for generic conversion from different types (strings, (string, u16) tuples, etc.) into a SocketAddr instance. It supports multiple output SocketAddresses when it is appropriate (e.g. DNS name resolution). This trait is going to be used by TcpStream, TcpListener and UdpSocket structures.
2014-11-04libsyntax: Forbid escapes in the inclusive range `\x80`-`\xff` inPatrick Walton-0/+32
Unicode characters and strings. Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected. This PR introduces a new function, `escape_default`, into the ASCII module. This was necessary for the pretty printer to continue to function. RFC #326. Closes #18062. [breaking-change]
2014-11-04std::error: fix stray doc commentAaron Turon-3/+0
2014-11-03rollup merge of #18578 : japaric/cloneAlex Crichton-2/+0
2014-11-03rollup merge of #18536 : bjz/strconvAlex Crichton-544/+276
2014-11-03std: Fix fallout of changing `#[deriving(Clone)]`Jorge Aparicio-2/+0
2014-11-03rollup merge of #18537 : japaric/no-secretAlex Crichton-0/+6
2014-11-03rollup merge of #18519 : Gankro/collect-smashAlex Crichton-41/+37
2014-11-03auto merge of #18468 : jakub-/rust/iter-repeat, r=alexcrichtonbors-1/+1
Implements a part of RFC 235. [breaking-change]
2014-11-04Deprecate {f32, f64}::from_str_hexBrendan Zabarauskas-80/+27
This is now covered by `FromStrRadix::from_str_radix`
2014-11-04Simplify float string conversion function furtherBrendan Zabarauskas-161/+115
We now have a really simple function signature: pub fn from_str_radix_float<T: Float>(src: &str, radix: uint) -> Option<T> By removing some of the arguments, we remove the possibility of some invalid states.
2014-11-04Clean up from_str_float and use iteratorsBrendan Zabarauskas-156/+125
2014-11-04Remove unnecessary features from strconvBrendan Zabarauskas-121/+33
2014-11-04Separate string->integer implementation in strconvBrendan Zabarauskas-181/+131
2014-11-03auto merge of #18463 : japaric/rust/bytes2, r=alexcrichtonbors-55/+32
- The `BytesContainer::container_into_owned_bytes` method has been removed - Methods that used to take `BytesContainer` implementors by value, now take them by reference. In particular, this breaks some uses of Path: ``` rust Path::new("foo") // Still works path.join(another_path) -> path.join(&another_path) ``` [breaking-change] --- Re: `container_into_owned_bytes`, I've removed it because - Nothing in the whole repository uses it - Takes `self` by value, which is incompatible with unsized types (`str`) The alternative to removing this method is to split `BytesContainer` into `BytesContainer for Sized?` and `SizedBytesContainer: BytesContainer + Sized`, where the second trait only contains the `container_into_owned_bytes` method. I tried this alternative [in another branch](https://github.com/japaric/rust/commits/bytes) and it works, but it seemed better not to create a new trait for an unused method. Re: Breakage of `Path` methods We could use the idea that @alexcrichton proposed in #18457 (add blanket `impl BytesContainer for &T where T: BytesContainer` + keep taking `T: BytesContainer` by value in `Path` methods) to avoid breaking any code. r? @aturon cc #16918
2014-11-02refactor libcollections as part of collection reformAlexis Beingessner-41/+37
* Moves multi-collection files into their own directory, and splits them into seperate files * Changes exports so that each collection has its own module * Adds underscores to public modules and filenames to match standard naming conventions (that is, treemap::{TreeMap, TreeSet} => tree_map::TreeMap, tree_set::TreeSet) * Renames PriorityQueue to BinaryHeap * Renames SmallIntMap to VecMap * Miscellanious fallout fixes [breaking-change]
2014-11-02Add Error impls to a few key error typesAaron Turon-0/+32
2014-11-02Add error module with Error and FromError traitsAaron Turon-4/+122
As per [RFC 70](https://github.com/rust-lang/rfcs/blob/master/active/0070-error-chaining.md) Closes #17747 Note that the `error` module must live in `std` in order to refer to `String`. Note that, until multidispatch lands, the `FromError` trait cannot be usefully implemented outside of the blanket impl given here.
2014-11-02core: Replace secret formatting functions with UFCS versionsJorge Aparicio-0/+6
2014-11-01Remove unnecessary allocationsJorge Aparicio-1/+1
2014-11-01DSTify BytesContainerJorge Aparicio-54/+31
2014-11-01bubble up out-of-memory errors from liballocDaniel Micay-1/+2
This makes the low-level allocation API suitable for use cases where out-of-memory conditions need to be handled. Closes #18292 [breaking-change]
2014-11-01auto merge of #18474 : alexcrichton/rust/no-more-traits, r=aturonbors-157/+383
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
2014-11-01collections: Remove all collections traitsAlex Crichton-157/+383
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
2014-11-01auto merge of #18457 : japaric/rust/tocstr, r=alexcrichtonbors-24/+0
Methods that used to take `ToCStr` implementors by value, now take them by reference. In particular, this breaks some uses of `Command`: ``` rust Command::new("foo"); // Still works Command::new(path) -> Command::new(&path) cmd.arg(string) -> cmd.arg(&string) or cmd.arg(string.as_slice()) ``` [breaking-change] --- It may be sensible to remove `impl ToCstr for String` since: - We're getting `impl Deref<str> for String`, so `string.to_cstr()` would still work - `Command` methods would still be able to use `cmd.arg(string[..])` instead of `cmd.arg(&string)`. But, I'm leaving that up to the library stabilization process. r? @aturon cc #16918
2014-10-31DSTify ToCStrJorge Aparicio-24/+0
2014-10-31DSTify HashJorge Aparicio-14/+17
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from: ``` hashmap.find_equiv(&"Hello"); hashmap.find_equiv(&&[0u8, 1, 2]); ``` to: ``` hashmap.find_equiv("Hello"); hashmap.find_equiv(&[0u8, 1, 2]); ``` - The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example: ``` impl Hasher<FnvState> for FnvHasher { fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } } ``` must be changed to: ``` impl Hasher<FnvState> for FnvHasher { fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ } // ^^^^^^ } ``` [breaking-change]
2014-10-30Test fixes and rebase conflictsAlex Crichton-1/+2
2014-10-30rollup merge of #18445 : alexcrichton/index-mutAlex Crichton-25/+21
Conflicts: src/libcollections/vec.rs
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-40/+40
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs