summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
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
2014-04-11auto merge of #13395 : Ryman/rust/bytecontainer_impl_container, r=alexcrichtonbors-46/+32
Also some minor cleanup in Path related to this.
2014-04-11Simplify GenericPath::set_extension.Kevin Butler-34/+21
2014-04-11Parameterize contains_nul for BytesContainer.Kevin Butler-12/+11
2014-04-11auto merge of #13458 : huonw/rust/doc-signatures, r=alexcrichtonbors-27/+44
Add more type signatures to the docs; tweak a few of them. Someone reading the docs won't know what the types of various things are, so this adds them in a few meaningful places to help with comprehension. cc #13423.
2014-04-11auto merge of #13236 : liigo/rust/rename-benchharness, r=huonwbors-265/+265
Closes #12640 based on PR #13030, rebased, and passed all tests.
2014-04-11Add more type signatures to the docs; tweak a few of them.Huon Wilson-27/+44
Someone reading the docs won't know what the types of various things are, so this adds them in a few meaningful places to help with comprehension. cc #13423.
2014-04-11libtest: rename `BenchHarness` to `Bencher`Liigo Zhuang-265/+265
Closes #12640
2014-04-11auto merge of #13457 : alexcrichton/rust/issue-13420, r=thestingerbors-0/+2
On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is necessary to deallocate that memory. Closes #13420
2014-04-10std: Be sure to call pthread_attr_destroyAlex Crichton-0/+2
On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is necessary to deallocate that memory. Closes #13420
2014-04-10std: Make std::comm return types consistentAlex Crichton-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-10auto merge of #13440 : huonw/rust/strbuf, r=alexcrichtonbors-499/+484
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it. Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
2014-04-11Fix tests. Add Vec<u8> conversion to StrBuf.Huon Wilson-2/+21
2014-04-10rustc: Don't allow priv use to shadow pub useAlex Crichton-1/+0
Previously, a private use statement would shadow a public use statement, all of a sudden publicly exporting the privately used item. The correct behavior here is to only shadow the use for the module in question, but for now it just reverts the entire name to private so the pub use doesn't have much effect. The behavior isn't exactly what we want, but this no longer has backwards compatibility hazards.
2014-04-10Stop using transmute_mut in RefCellSteven Fackler-21/+17
This is supposedly undefined behavior now that Unsafe exists, so we'll use Cell instead.
2014-04-10std,syntax: make std::fmt::parse use `Vec`s.Huon Wilson-58/+58
2014-04-10std,native,green,rustuv: make readdir return `Vec`.Huon Wilson-3/+4
Replacing `~[]`. This also makes the `walk_dir` iterator use a `Vec` internally.
2014-04-10std,serialize: remove some internal uses of ~[].Huon Wilson-37/+41
These are all private uses of ~[], so can easily & non-controversially be replaced with Vec.
2014-04-10libstd: Implement `StrBuf`, a new string buffer type like `Vec`, andPatrick Walton-498/+464
port all code over to use it.
2014-04-09std: use a `match` in `assert_eq!` to extend the lifetime of the args.Huon Wilson-7/+9
This enables assert_eq!(foo.collect::<Vec<...>>().as_slice(), &[1,2,3,4]); to work, by extending the lifetime of the .as_slice() rvalue.
2014-04-08rustc: Remove f{32,64} % from the languageAlex Crichton-2/+8
This commit removes the compiler support for floating point modulus operations, as well as from the language. An implementation for this operator is now required to be provided by libraries. Floating point modulus is rarely used, doesn't exist in C, and is always lowered to an fmod library call by LLVM, and LLVM is considering removing support entirely. Closes #12278
2014-04-08auto merge of #13399 : SimonSapin/rust/patch-8, r=cmrbors-1/+1
2014-04-08Update an obsolete comment about conditionsSimon Sapin-1/+1
2014-04-08std: make vec!() macro handle a trailing commaKang Seonghoon-1/+2
Fixes #12910.
2014-04-08Fix spelling errors in comments.Joseph Crail-4/+4
2014-04-08std: User a smaller stdin buffer on windowsAlex Crichton-1/+9
Apparently windows doesn't like reading from stdin with a large buffer size, and it also apparently is ok with a smaller buffer size. This changes the reader returned by stdin() to return an 8k buffered reader for stdin rather than a 64k buffered reader. Apparently libuv has run into this before, taking a peek at their code, with a specific comment in their console code saying that "ReadConsole can't handle big buffers", which I presume is related to invoking ReadFile as if it were a file descriptor. Closes #13304
2014-04-08Improve searching for XXX in tidy script (#3303)Boris Egorov-1/+1
Few places where previous version of tidy script cannot find XXX: * inside one-line comment preceding by a few spaces; * inside multiline comments (now it finds it if multiline comment starts on the same line with XXX). Change occurences of XXX found by new tidy script.
2014-04-08std: Add more docs for ptr modBrian Anderson-53/+182
2014-04-08Register new snapshotsAlex Crichton-61/+61
2014-04-07auto merge of #13358 : tbu-/rust/pr_doc_equivrel, r=cmrbors-63/+72
Add requirements of TotalEq and TotalOrd Clarify that TotalEq needs an underlying equivalence relation and that TotalOrd needs a total ordering and specifically named the required (and sufficient) attributes.
2014-04-07auto merge of #13356 : alexcrichton/rust/ignore-flaky, r=huonwbors-1/+1
This test relies on the parent to be descheduled before the child sends its data. This has proved to be unreliable on libnative on the bots. It's a fairly trivial test regardless, so ignoring it for now won't lose much.