about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-02-20Mass rename if_ok! to try!Alex Crichton-101/+101
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20auto merge of #12397 : alexcrichton/rust/send-off-the-runtime, r=brsonbors-10/+49
The fairness yield mistakenly called `Local::take()` which meant that it would only work if a local task was available. In theory sending on a channel (or calling try_recv) requires no runtime because it never blocks, so there's no reason it shouldn't support such a use case. Closes #12391
2014-02-20auto merge of #12343 : liigo/rust/move-extra-test-to-libtest, r=alexcrichtonbors-21/+34
I don't think `extra` is a good/meaningful name for a library. `libextra` should disappear, and we move all of its sub modules out of it. This PR is just one of that steps: move `extra::test` to `libtest`. I didn't add `libtest` to doc index, because it's an internal library currently. **Update:** All comments addressed. All tests passed. Rebased and squashed.
2014-02-20auto merge of #12396 : alexcrichton/rust/windows-env-var, r=huonwbors-1/+13
On windows, the GetEnvironmentVariable function will return the necessary buffer size if the buffer provided was too small. This case previously fell through the checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice` method. This adds an extra case for when the return value is >= the buffer size, in which case we assume the return value as the new buffer size and try again. Closes #12376
2014-02-20move extra::test to libtestLiigo Zhuang-21/+34
2014-02-19Fix sending/try_recv on channels off the runtimeAlex Crichton-10/+49
The fairness yield mistakenly called `Local::take()` which meant that it would only work if a local task was available. In theory sending on a channel (or calling try_recv) requires no runtime because it never blocks, so there's no reason it shouldn't support such a use case. Closes #12391
2014-02-19Fix getting/setting huge env vars on windowsAlex Crichton-1/+13
On windows, the GetEnvironmentVariable function will return the necessary buffer size if the buffer provided was too small. This case previously fell through the checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice` method. This adds an extra case for when the return value is >= the buffer size, in which case we assume the return value as the new buffer size and try again. Closes #12376
2014-02-19auto merge of #12374 : dylanbraithwaite/rust/size_of_unit_clarification, r=cmrbors-5/+5
Changed the docs for std::mem to clarify the fact that the size functions return sizes in bytes.
2014-02-19rustdoc: Handle links to reexported itemsAlex Crichton-2/+5
When building up our path cache, we don't plaster over a path which was previously inserted if we're inserting a non-public-item thing. Closes #11678
2014-02-19rustdoc: Show macros in documentationAlex Crichton-1/+173
Any macro tagged with #[macro_export] will be showed in the documentation for that module. This also documents all the existing macros inside of std::macros. Closes #3163 cc #5605 Closes #9954
2014-02-18auto merge of #12317 : huonw/rust/utf16, r=alexcrichtonbors-50/+305
Iterators! Use them (in `is_utf16`), create them (in `utf16_items`). Handle errors gracefully (`from_utf16_lossy`) and `from_utf16` returning `Option<~str>` instead of failing. Add a pile of tests.
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-3/+51
Many of the functions interacting with Windows APIs allocate a vector of 0's and do not retrieve a length directly from the API call, and so need to be sure to remove the unmodified junk at the end of the vector.
2014-02-18Clarify unit of size in docs for size_of functions.Dylan Braithwaite-5/+5
Changed the docs in mem.rs to clarify the fact the the size functions return sizes in bytes.
2014-02-18auto merge of #12357 : chromatic/rust/gh_11976_fail_bounds_check_str, ↵bors-2/+12
r=alexcrichton Fixes #11976.
2014-02-18auto merge of #12314 : huonw/rust/is_utf8_iter, r=kballardbors-45/+70
See the commit messages for more details, but this makes `std::str::is_utf8` slightly faster and 100% non-`unsafe` and uses a similar thing to make the first scan of `from_utf8_lossy` 100% safe & faster.
2014-02-18std: convert first_non_utf8_byte to use the iterator.Huon Wilson-61/+11
This makes it very slightly faster, especially when the string is valid UTF-8, and completely removes the use of `unsafe` from the first half. Before: from_utf8_lossy_100_ascii ... bench: 151 ns/iter (+/- 17) from_utf8_lossy_100_invalid ... bench: 447 ns/iter (+/- 33) from_utf8_lossy_100_multibyte ... bench: 135 ns/iter (+/- 4) from_utf8_lossy_invalid ... bench: 124 ns/iter (+/- 10 After: from_utf8_lossy_100_ascii ... bench: 119 ns/iter (+/- 8) from_utf8_lossy_100_invalid ... bench: 454 ns/iter (+/- 16) from_utf8_lossy_100_multibyte ... bench: 116 ns/iter (+/- 9) from_utf8_lossy_invalid ... bench: 119 ns/iter (+/- 9)
2014-02-18std::str: safen and optimize is_utf8.Huon Wilson-2/+77
This uses a vector iterator to avoid the necessity for unsafe indexing, and makes this function slightly faster. Unfortunately #11751 means that the iterator comes with repeated `null` checks which means the pure-ASCII case still has room for significant improvement (and the other cases too, but it's most significant for just ASCII). Before: is_utf8_100_ascii ... bench: 143 ns/iter (+/- 6) is_utf8_100_multibyte ... bench: 134 ns/iter (+/- 4) After: is_utf8_100_ascii ... bench: 123 ns/iter (+/- 4) is_utf8_100_multibyte ... bench: 115 ns/iter (+/- 5)
2014-02-18auto merge of #12345 : huonw/rust/speeling, r=cmrbors-7/+6
2014-02-17auto merge of #12321 : bjz/rust/remove-real, r=alexcrichtonbors-504/+494
This is part of the effort to simplify `std::num`, as tracked in issue #10387. It is also a step towards a proper IEEE-754 trait (see #12281).
2014-02-17auto merge of #12103 : alexcrichton/rust/unix, r=brsonbors-42/+134
There's a few parts to this PR * Implement unix pipes in libnative for unix platforms (thanks @Geal!) * Implement named pipes in libnative for windows (terrible, terrible code) * Remove `#[cfg(unix)]` from `mod unix` in `std::io::net`. This is a terrible name for what it is, but that's the topic of #12093. The windows implementation was significantly more complicated than I thought it would be, but it seems to be passing all the tests. now. Closes #11201
2014-02-17Made fail_bounds_check more careful with strings.chromatic-2/+12
Fixes GH #11976.
2014-02-17auto merge of #12232 : kballard/rust/taskbuilder-is-a-builder, r=alexcrichtonbors-95/+26
Delete all the documentation from std::task that references linked failure. Tweak TaskBuilder to be more builder-like. `.name()` is now `.named()` and `.add_wrapper()` is now `.with_wrapper()`. Remove `.watched()` and `.unwatched()` as they didn't actually do anything. Closes #6399.
2014-02-17Fix a deadlock in channels, again.Alex Crichton-4/+4
This deadlock was caused when the channel was closed at just the right time, so the extra `self.cnt.fetch_add` actually should have preserved the DISCONNECTED state of the channel. by modifying this the channel entered a state such that the port would never succeed in dropping. This also moves the increment of self.steals until after the MAX_STEALS block. The reason for this is that in 'fn recv()' the steals variable is decremented immediately after the try_recv(), which could in theory set steals to -1 if it was previously set to 0 in try_recv(). Closes #12340
2014-02-18Spellcheck library docs.Huon Wilson-7/+6
2014-02-17auto merge of #12331 : bjz/rust/count-ones, r=alexcrichtonbors-39/+89
This is inspired by the [function naming in the Julia standard library](http://docs.julialang.org/en/release-0.2/stdlib/base/#Base.count_ones). It seems like a more self-explanatory name, and is more consistent with the accompanying methods, `leading_zeros` and `trailing_zeros`.
2014-02-17auto merge of #12325 : big-guy/rust/doc-fixes, r=alexcrichtonbors-3/+3
* Change '...your own time' => '...your own type' * Fix typo in the Vector2D example
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-23/+46
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-17std: decode even numbered non-BMP planes in the UTF-16 decoder.Huon Wilson-2/+5
Fixes #12318.
2014-02-17str: provide lossy UTF-16 support.Huon Wilson-23/+133
This replaces the iterator with one that handles lone surrogates gracefully and uses that to implement `from_utf16_lossy` which replaces invalid `u16`s with U+FFFD.
2014-02-17std: convert str::from_utf16 to an external iterator.Huon Wilson-27/+38
Fixes #12316.
2014-02-17std: iteratize str::is_utf16 & add tests.Huon Wilson-18/+78
Most of the tests are randomly generated with Python 3 and rely on it's UTF-16be encoder/decoder being correct.
2014-02-17Rename Bitwise::population_count to Bitwise::count_ones and add ↵Brendan Zabarauskas-39/+89
Bitwise::count_zeros These are inspired by the [functions in the Julia standard library](http://docs.julialang.org/en/release-0.2/stdlib/base/#Base.count_ones).
2014-02-16Implement named pipes for windows, touch up unixAlex Crichton-51/+114
* Implementation of pipe_win32 filled out for libnative * Reorganize pipes to be clone-able * Fix a few file descriptor leaks on error * Factor out some common code into shared functions * Make use of the if_ok!() macro for less indentation Closes #11201
2014-02-16Implement Unix domain sockets in libnativeGeoffroy Couprie-0/+29
2014-02-16Allow configuration of uid/gid/detach on processesAlex Crichton-31/+138
This just copies the libuv implementation for libnative which seems reasonable enough (uid/gid fail on windows). Closes #12082
2014-02-16Clean up std::task docs, make TaskBuilder a real builderKevin Ballard-95/+26
Delete all the documentation from std::task that references linked failure. Tweak TaskBuilder to be more builder-like. .name() is now .named() and .add_wrapper() is now .with_wrapper(). Remove .watched() and .unwatched() as they didn't actually do anything.
2014-02-16Minor documentation fixes in std::fmtSterling Greene-3/+3
* Change '...your own time' => '...your own type' * Fix typo in the Vector2D example
2014-02-17Remove Real trait and move methods into FloatBrendan Zabarauskas-504/+494
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
2014-02-16auto merge of #12313 : bjz/rust/tuple, r=huonwbors-289/+179
This renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters. It also removes the `CloneableTuple` and `ImmutableTuple` traits.
2014-02-17Remove CloneableTuple and ImmutableTuple traitsBrendan Zabarauskas-81/+5
These are adequately covered by the Tuple2 trait.
2014-02-17Improve naming of tuple getters, and add mutable tuple getterBrendan Zabarauskas-125/+128
Renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters.
2014-02-16Merge ImmutableTuple* traits into their respective Tuple* traitBrendan Zabarauskas-38/+16
2014-02-16Delegate ToStr implementation to Show for tuplesBrendan Zabarauskas-48/+7
2014-02-16Implement Show for 1-12 element tuplesBrendan Zabarauskas-0/+26
2014-02-15auto merge of #12302 : alexcrichton/rust/issue-12295, r=brsonbors-10/+28
The previous code erroneously assumed that 'steals > cnt' was always true, but that was a false assumption. The code was altered to decrement steals to a minimum of 0 instead of taking all of cnt into account. I didn't include the exact test from #12295 because it could run for quite awhile, and instead set the threshold for MAX_STEALS to much lower during testing. I found that this triggered the old bug quite frequently when running without this fix. Closes #12295
2014-02-15auto merge of #12299 : sfackler/rust/limit-return, r=alexcrichtonbors-2/+24
This is useful in contexts like this: ```rust let size = rdr.read_be_i32() as uint; let mut limit = LimitReader::new(rdr.by_ref(), size); let thing = read_a_thing(&mut limit); assert!(limit.limit() == 0); ```
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-52/+80
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15Correctly reset steals when hitting MAX_STEALSAlex Crichton-7/+28
The previous code erroneously assumed that 'steals > cnt' was always true, but that was a false assumption. The code was altered to decrement steals to a minimum of 0 instead of taking all of cnt into account. I didn't include the exact test from #12295 because it could run for quite awhile, and instead set the threshold for MAX_STEALS to much lower during testing. I found that this triggered the old bug quite frequently when running without this fix. Closes #12295
2014-02-15Silence some unused import warningsAlex Crichton-3/+0
2014-02-15auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichtonbors-146/+276
- adds a `LockGuard` type returned by `.lock` and `.trylock` that unlocks the mutex in the destructor - renames `mutex::Mutex` to `StaticNativeMutex` - adds a `NativeMutex` type with a destructor - removes `LittleLock` - adds `#[must_use]` to `sync::mutex::Guard` to remind people to use it