summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-04-19Have floating point functions take their parameters by value.Brendan Zabarauskas-154/+154
Make all of the methods in `std::num::Float` take `self` and their other parameters by value. Some of the `Float` methods took their parameters by value, and others took them by reference. This standardises them to one convention. The `Float` trait is intended for the built in IEEE 754 numbers only so we don't have to worry about the trait serving types of larger sizes. [breaking-change]
2014-04-19Merge the Round trait into the Float traitBrendan Zabarauskas-78/+71
Move the rounding functions into the `std::num::Float` trait and then remove `std::num::Round`. This continues the flattening of the numeric traits tracked in #10387. The aim is to make `std::num` very simple and tied to the built in types, leaving the definition of more complex numeric towers to third-party libraries. [breaking-change]
2014-04-18std: Fix demangling with middle special charsAlex Crichton-3/+13
Previously, symbols with rust escape sequences (denoted with dollar signs) weren't demangled if the escape sequence showed up in the middle. This alters the printing loop to look through the entire string for dollar characters.
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-505/+543
2014-04-18Reduce HashMap allocations.Clark Gaebel-0/+6
2014-04-18std: Fix compiling on FreeBSDAlex Crichton-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-18Fix a couple places in docs where try_send wasn't changed to send_optJames Sanders-2/+2
2014-04-18Update the rest of the compiler with ~[T] changesAlex Crichton-25/+20
2014-04-18std: Fail more gracefully on thread spawn errorsAlex Crichton-4/+17
On windows, correctly check for errors when spawning threads, and on both windows and unix handle the error more gracefully rather than printing an opaque assertion failure. Closes #13589
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-999/+342
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-17auto merge of #13580 : DiamondLovesYou/rust/std-result-hash, r=alexcrichtonbors-1/+1
Title says it all.
2014-04-17auto merge of #13558 : alexcrichton/rust/snapshots, r=brsonbors-25/+1
This is the first snapshot build by mingw-w64 with the win32 threading model I believe (Closes #13501). Curiously, this successfully built a snapshot on freebsd when the auto builder is continuously segfaulting. Who knew!
2014-04-17Add #[deriving(Hash)] to Result.Richard Diamond-1/+1
2014-04-16auto merge of #13499 : brson/rust/resultdocs, r=brsonbors-5/+325
This adds some fairly extensive documentation for `Result`. I'm using manual links to other rustdoc html pages a bit.
2014-04-16auto merge of #13465 : alexcrichton/rust/fix-comm-dox, r=brsonbors-23/+77
Some of this documentation got a little out of date. There was no mention of a `SyncSender`, and the entire "Outside the runtime" section isn't really true any more (or really all that relevant). This also updates a few other doc blocks and adds some examples.
2014-04-16doc: Address review feedbackBrian Anderson-17/+14
2014-04-16std: Improve docs for mod 'result'Brian Anderson-5/+328
2014-04-16Register new snapshotsAlex Crichton-25/+1
2014-04-16auto merge of #13539 : Aatch/rust/vector-copy-faster, r=thestingerbors-5/+38
LLVM wasn't recognising the loops as memcpy loops and was therefore failing to optimise them properly. While improving LLVM is the "proper" way to fix this, I think that these cases are important enough to warrant a little low-level optimisation. Fixes #13472 r? @thestinger --- Benchmark Results: ``` --- Before --- test clone_owned ... bench: 6126104 ns/iter (+/- 285962) = 170 MB/s test clone_owned_to_owned ... bench: 6125054 ns/iter (+/- 271197) = 170 MB/s test clone_str ... bench: 80586 ns/iter (+/- 11489) = 13011 MB/s test clone_vec ... bench: 3903220 ns/iter (+/- 658556) = 268 MB/s test test_memcpy ... bench: 69401 ns/iter (+/- 2168) = 15108 MB/s --- After --- test clone_owned ... bench: 70839 ns/iter (+/- 4931) = 14801 MB/s test clone_owned_to_owned ... bench: 70286 ns/iter (+/- 4836) = 14918 MB/s test clone_str ... bench: 78519 ns/iter (+/- 5511) = 13353 MB/s test clone_vec ... bench: 71415 ns/iter (+/- 1999) = 14682 MB/s test test_memcpy ... bench: 70980 ns/iter (+/- 2126) = 14772 MB/s ```
2014-04-16auto merge of #13522 : seanmonstar/rust/sip, r=alexcrichtonbors-42/+143
work started from @gereeter's PR: https://github.com/mozilla/rust/pull/13114 but adjusted bits ``` before test hash::sip::tests::bench_u64 ... bench: 34 ns/iter (+/- 0) test hash::sip::tests::bench_str_under_8_bytes ... bench: 37 ns/iter (+/- 1) test hash::sip::tests::bench_str_of_8_bytes ... bench: 43 ns/iter (+/- 1) test hash::sip::tests::bench_str_over_8_bytes ... bench: 50 ns/iter (+/- 1) test hash::sip::tests::bench_long_str ... bench: 613 ns/iter (+/- 14) test hash::sip::tests::bench_compound_1 ... bench: 114 ns/iter (+/- 11) after test hash::sip::tests::bench_u64 ... bench: 25 ns/iter (+/- 0) test hash::sip::tests::bench_str_under_8_bytes ... bench: 31 ns/iter (+/- 0) test hash::sip::tests::bench_str_of_8_bytes ... bench: 36 ns/iter (+/- 0) test hash::sip::tests::bench_str_over_8_bytes ... bench: 40 ns/iter (+/- 0) test hash::sip::tests::bench_long_str ... bench: 600 ns/iter (+/- 14) test hash::sip::tests::bench_compound_1 ... bench: 64 ns/iter (+/- 6) ``` Notably it seems smaller keys will hash faster. A long string doesn't see much gains, but compound cuts in half (once compound used a `int` and `u64`).
2014-04-15auto merge of #13532 : alexcrichton/rust/rollup, r=alexcrichtonbors-127/+159
2014-04-15std: Un-ignore some float tests on windowsAlex Crichton-2/+2
These were fixed in the upgrade from mingw32 to mingw64. Closes #8663
2014-04-15std: Remove pub use globsBrian Anderson-13/+25
2014-04-15Add a default impl for Set::is_supersetSteven Fackler-1/+3
I also deleted a bunch of documentation that was copy/pasted from the trait definition.
2014-04-15Use the unsigned integer types for bitwise intrinsics.Huon Wilson-85/+109
Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just exposing the internal LLVM names pointlessly (LLVM doesn't have "signed integers" or "unsigned integers", it just has sized integer types with (un)signed *operations*). These operations are semantically working with raw bytes, which the unsigned types model better.
2014-04-15std: Impl Deref/DerefMut for a borrowed taskAlex Crichton-26/+20
2014-04-16Make Vec::clone and slice::to_owned failure-safeJames Miller-17/+19
2014-04-15auto merge of #13498 : johnsoft/rust/fix-transmute-fn-names, r=alexcrichtonbors-7/+7
Regions were renamed to lifetimes a while back, so these functions should probably be renamed as well.
2014-04-16Improve the copying code for slices and VecJames Miller-5/+36
2014-04-15optimized SipHash implementationSean McArthur-42/+143
work started from @gereeter's PR: https://github.com/mozilla/rust/pull/13114 but adjusted bits
2014-04-15std: Update documentation on the `comm` moduleAlex Crichton-23/+77
Some of this documentation got a little out of date. There was no mention of a `SyncSender`, and the entire "Outside the runtime" section isn't really true any more (or really all that relevant). This also updates a few other doc blocks and adds some examples.
2014-04-14Use new attribute syntax in python files in src/etc too (#13478)Manish Goregaokar-28/+28
2014-04-14auto merge of #13481 : huonw/rust/devec-path, r=alexcrichtonbors-183/+209
Remove the use of ~[] from Path's internals.
2014-04-13Make Result::{unwrap, unwrap_err} require ShowSteven Fackler-15/+20
`foo.ok().unwrap()` and `foo.err().unwrap()` are the fallbacks for types that aren't `Show`. Closes #13379
2014-04-13auto merge of #13475 : Ryman/rust/result_unwrap_or_else, r=brsonbors-0/+61
It might make more sense to mirror `Option`'s `unwrap_or_else` but I've left it as `handle` as it feels more explicit about the signature difference.
2014-04-13auto merge of #13464 : alexcrichton/rust/fix-rustdoc-rendering, r=brsonbors-2/+7
Closures did not have their bounds printed at all, nor their lifetimes. Trait bounds were also printed in angle brackets rather than after a colon with a '+' inbetween them. Note that on the current task::spawn [1] documentation page, there is no mention of a `Send` bound even though it is crucially important! [1] - http://static.rust-lang.org/doc/master/std/task/fn.task.html
2014-04-13Replace 'region' with 'lifetime' in a few transmute function namesJohn Simon-7/+7
2014-04-13auto merge of #13470 : Manishearth/rust/docnum, r=brsonbors-0/+4
See #7511
2014-04-13rustdoc: Fix rendering closures and trait boundsAlex Crichton-2/+7
Closures did not have their bounds printed at all, nor their lifetimes. Trait bounds were also printed in angle brackets rather than after a colon with a '+' inbetween them. Note that on the current task::spawn [1] documentation page, there is no mention of a `Send` bound even though it is crucially important! [1] - http://static.rust-lang.org/doc/master/std/task/fn.task.html
2014-04-13auto merge of #13469 : kmcallister/rust/utf16, r=huonwbors-19/+61
This fixes two separate issues related to character encoding. * Add `encode_utf16` to the `Char` trait, analogous to `encode_utf8`. `&str` already supports UTF-16 encoding but only with a heap allocation. Also fix `encode_utf8` docs and add tests. * Correctly decode non-BMP hex escapes in JSON (#13064).
2014-04-13auto merge of #13468 : alexcrichton/rust/issue-13467, r=thestingerbors-2/+46
Previously, all slices derived from a vector whose values were of size 0 had a null pointer as the 'data' pointer on the slice. This caused first pointer to be yielded during iteration to always be the null pointer. Due to the null pointer optimization, this meant that the first return value was None, instead of Some(&T). This commit changes slice construction from a Vec instance to use a base pointer of 1 if the values have zero size. This means that the iterator will never return null, and the iteration will proceed appropriately. Closes #13467
2014-04-12auto merge of #13448 : alexcrichton/rust/rework-chan-return-values, r=brsonbors-177/+187
There are currently a number of return values from the std::comm methods, not all of which are necessarily completely expressive: * `Sender::try_send(t: T) -> bool` This method currently doesn't transmit back the data `t` if the send fails due to the other end having disconnected. Additionally, this shares the name of the synchronous try_send method, but it differs in semantics in that it only has one failure case, not two (the buffer can never be full). * `SyncSender::try_send(t: T) -> TrySendResult<T>` This method accurately conveys all possible information, but it uses a custom type to the std::comm module with no convenience methods on it. Additionally, if you want to inspect the result you're forced to import something from `std::comm`. * `SyncSender::send_opt(t: T) -> Option<T>` This method uses Some(T) as an "error value" and None as a "success value", but almost all other uses of Option<T> have Some/None the other way * `Receiver::try_recv(t: T) -> TryRecvResult<T>` Similarly to the synchronous try_send, this custom return type is lacking in terms of usability (no convenience methods). With this number of drawbacks in mind, I believed it was time to re-work the return types of these methods. The new API for the comm module is: Sender::send(t: T) -> () Sender::send_opt(t: T) -> Result<(), T> SyncSender::send(t: T) -> () SyncSender::send_opt(t: T) -> Result<(), T> SyncSender::try_send(t: T) -> Result<(), TrySendError<T>> Receiver::recv() -> T Receiver::recv_opt() -> Result<T, ()> Receiver::try_recv() -> Result<T, TryRecvError> The notable changes made are: * Sender::try_send => Sender::send_opt. This renaming brings the semantics in line with the SyncSender::send_opt method. An asychronous send only has one failure case, unlike the synchronous try_send method which has two failure cases (full/disconnected). * Sender::send_opt returns the data back to the caller if the send is guaranteed to fail. This method previously returned `bool`, but then it was unable to retrieve the data if the data was guaranteed to fail to send. There is still a race such that when `Ok(())` is returned the data could still fail to be received, but that's inherent to an asynchronous channel. * Result is now the basis of all return values. This not only adds lots of convenience methods to all return values for free, but it also means that you can inspect the return values with no extra imports (Ok/Err are in the prelude). Additionally, it's now self documenting when something failed or not because the return value has "Err" in the name. Things I'm a little uneasy about: * The methods send_opt and recv_opt are not returning options, but rather results. I felt more strongly that Option was the wrong return type than the _opt prefix was wrong, and I coudn't think of a much better name for these methods. One possible way to think about them is to read the _opt suffix as "optionally". * Result<T, ()> is often better expressed as Option<T>. This is only applicable to the recv_opt() method, but I thought it would be more consistent for everything to return Result rather than one method returning an Option. Despite my two reasons to feel uneasy, I feel much better about the consistency in return values at this point, and I think the only real open question is if there's a better suffix for {send,recv}_opt. Closes #11527
2014-04-12std: update & de-~[] path's tests.Huon Wilson-57/+42
2014-04-12std: migrate path::windows to using StrBuf internally.Huon Wilson-64/+97
Same representation change performed with path::unix. This also implements BytesContainer for StrBuf & adds an (unsafe) method for viewing & mutating the raw byte vector of a StrBuf.
2014-04-12std: migrate path::unix to using Vec internally.Huon Wilson-64/+72
2014-04-12libstd: Add unwrap_or and unwrap_or_handle to ResultKevin Butler-0/+61
2014-04-12Document traits in std::num (#7511)Manish Goregaokar-0/+4
2014-04-11Add tests for Char::encode_utf{8,16}Keegan McAllister-0/+29
2014-04-11Implement Char::encode_utf16Keegan McAllister-19/+32
And clean up encode_utf8 a bit.
2014-04-11std: Fix iteration over vectors of 0-size valuesAlex Crichton-2/+46
Previously, all slices derived from a vector whose values were of size 0 had a null pointer as the 'data' pointer on the slice. This caused first pointer to be yielded during iteration to always be the null pointer. Due to the null pointer optimization, this meant that the first return value was None, instead of Some(&T). This commit changes slice construction from a Vec instance to use a base pointer of 1 if the values have zero size. This means that the iterator will never return null, and the iteration will proceed appropriately. Closes #13467