about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-09-14std::logging: Use a more specific enum than Eitherblake2-ppc-18/+18
2013-09-13std: Fix another windows problem with the unwrap_or_default renameErick Tryzelaar-1/+1
2013-09-13std: rename Option.chain to Option.and_then on windowsErick Tryzelaar-1/+1
2013-09-13std::rt::io: Fix file I/O on Win32klutzy-0/+9
It was broken on win32 because of header inconsistency.
2013-09-12Improve the local_data docs slightlyAlex Crichton-7/+8
Remove references to local_data::Key and only mention the macro for how to construct new keys into local data.
2013-09-12auto merge of #9087 : fhahn/rust/rust_crate_map, r=brsonbors-54/+224
This patch converts the rust_crate_map.cpp to Rust as mentioned at the end of #8880.
2013-09-12Stop using newtypes in rt::io::bufferedSteven Fackler-13/+19
This is a workaround for #9155. Currently, any uses of BufferedStream outside of libstd ICE.
2013-09-12std: Restore Option::chain{,_mut}_ref as and_then{,_mut}_refErick Tryzelaar-16/+26
2013-09-12std: Remove Zero impl for OptionErick Tryzelaar-5/+0
Options are not numeric types, so it doesn't make sense for them to implement Zero.
2013-09-12std: Remove Zero impl from vecErick Tryzelaar-21/+4
Vecs are not numeric types, so it doesn't make sense for them to implement Zero.
2013-09-12std: Add a bunch of Default implsErick Tryzelaar-5/+75
2013-09-12std: Rename {Option,Result}::chain{,_err}* to {and_then,or_else}Erick Tryzelaar-55/+79
2013-09-12std: Add ToEither/IntoEither/AsEitherErick Tryzelaar-21/+162
2013-09-12std: Add ToResult/IntoResult/AsResultErick Tryzelaar-12/+171
2013-09-12std: Add ToOption/IntoOption/AsOptionErick Tryzelaar-0/+185
2013-09-12std: fix a warningErick Tryzelaar-1/+1
2013-09-12std: Add Option.{and,and_then,or,or_else}Erick Tryzelaar-8/+81
2013-09-12std: Add Option.unwrap_or_else and a couple testsErick Tryzelaar-0/+47
2013-09-12std: Add Default implementation for vecsErick Tryzelaar-0/+14
2013-09-12std: Add Option.{result_or_default,or_default} that uses DefaultErick Tryzelaar-0/+20
2013-09-12std: add default implementations to OptionErick Tryzelaar-0/+5
2013-09-12std: add default implementations to HashMapErick Tryzelaar-0/+9
2013-09-12std: rename Option::unwrap_or_default() to unwrap_or()Erick Tryzelaar-4/+4
2013-09-13Convert rust_crate_map.cpp to RustFlorian Hahn-54/+213
Conflicts: src/libstd/rt/logging.rs
2013-09-12auto merge of #9136 : thestinger/rust/ptr, r=alexcrichtonbors-4/+64
This is mostly for consistency, as you can now compare raw pointers in constant expressions or without the standard library. It also reduces the number of `ptrtoint` instructions in the IR, making tracking down culprits of what's usually an anti-pattern easier.
2013-09-12auto merge of #9140 : alexcrichton/rust/issue-9119, r=huonwbors-2/+2
Closes #9119
2013-09-12auto merge of #9012 : alexcrichton/rust/format-args, r=huonwbors-16/+75
The purpose of this macro is to further reduce the number of allocations which occur when dealing with formatting strings. This macro will perform all of the static analysis necessary to validate that a format string is safe, and then it will wrap up the "format string" into an opaque struct which can then be passed around. Two safe functions are added (write/format) which take this opaque argument structure, unwrap it, and then call the unsafe version of write/format (in an unsafe block). Other than these two functions, it is not intended for anyone to ever look inside this opaque struct. The macro looks a bit odd, but mostly because of rvalue lifetimes this is the only way for it to be safe that I know of. Example use-cases of this are: * third-party libraries can use the default formatting syntax without any forced allocations * the fail!() macro can avoid allocating the format string * the logging macros can avoid allocation any strings I plan on transitioning the standard logging/failing to using these macros soon. This is currently blocking on inner statics being usable in cross-crate situations (still tracking down bugs there), but this will hopefully be coming soon! Additionally, I'd rather settle on a name now than later, so if anyone has a better suggestion other than `format_args`, I'm not attached to the name at all :)
2013-09-12auto merge of #9138 : alexcrichton/rust/dynamic-lib-not-threadsafe, r=thestingerbors-1/+3
The library isn't thread-safe, cc #9137
2013-09-12Parse underscores in identifiers for format!Alex Crichton-2/+2
Closes #9119
2013-09-12Implement a format_args!() macroAlex Crichton-16/+75
The purpose of this macro is to further reduce the number of allocations which occur when dealing with formatting strings. This macro will perform all of the static analysis necessary to validate that a format string is safe, and then it will wrap up the "format string" into an opaque struct which can then be passed around. Two safe functions are added (write/format) which take this opaque argument structure, unwrap it, and then call the unsafe version of write/format (in an unsafe block). Other than these two functions, it is not intended for anyone to ever look inside this opaque struct. The macro looks a bit odd, but mostly because of rvalue lifetimes this is the only way for it to be safe that I know of. Example use-cases of this are: * third-party libraries can use the default formatting syntax without any forced allocations * the fail!() macro can avoid allocating the format string * the logging macros can avoid allocation any strings
2013-09-11Flag the dynamic_lib tests as ignoredAlex Crichton-1/+3
The library isn't thread-safe, cc #9137
2013-09-11auto merge of #9114 : sfackler/rust/flush-fix, r=brsonbors-1/+1
2013-09-12implement raw pointer comparisons in librustcDaniel Micay-4/+64
This is mostly for consistency, as you can now compare raw pointers in constant expressions or without the standard library. It also reduces the number of `ptrtoint` instructions in the IR, making tracking down culprits of what's usually an anti-pattern easier.
2013-09-11auto merge of #9038 : singingboyo/rust/with-mem-writer, r=anasazibors-0/+14
This is in many ways a replacement for the current std::io::with_str_writer.
2013-09-11auto merge of #8999 : anasazi/rust/multi-threaded-io-tests, r=brsonbors-51/+190
Resolves #8685
2013-09-11Add HashSet::with_capacity_and_keys() functionFlorian Hahn-0/+11
This function can be use to create HashSets before the tls is initialized.
2013-09-10Don't fail in TcpStream.flushSteven Fackler-1/+1
2013-09-10auto merge of #9091 : sfackler/rust/buffered, r=alexcrichtonbors-0/+358
The default buffer size is the same as the one in Java's BufferedWriter. We may want BufferedWriter to have a Drop impl that flushes, but that isn't possible right now due to #4252/#4430. This would be a bit awkward due to the possibility of the inner flush failing. For what it's worth, Java's BufferedReader doesn't have a flushing finalizer, but that may just be because Java's finalizer support is awful. The current implementation of BufferedStream is weird in my opinion, but it's what the discussion in #8953 settled on. I wrote a custom copy function since vec::copy_from doesn't optimize as well as I would like. Closes #8953
2013-09-10Buffered I/O wrappersSteven Fackler-0/+358
The default buffer size is the same as the one in Java's BufferedWriter. We may want BufferedWriter to have a Drop impl that flushes, but that isn't possible right now due to #4252/#4430. This would be a bit awkward due to the possibility of the inner flush failing. For what it's worth, Java's BufferedReader doesn't have a flushing finalizer, but that may just be because Java's finalizer support is awful. Closes #8953
2013-09-09auto merge of #9062 : blake2-ppc/rust/vec-iterator, r=alexcrichtonbors-255/+255
Visit the free functions of std::vec and reimplement or remove some. Most prominently, remove `each_permutation` and replace with two iterators, ElementSwaps and Permutations. Replace unzip, unzip_slice with an updated `unzip` that works with an iterator argument. Replace each_permutation with a Permutation iterator. The new permutation iterator is more efficient since it uses an algorithm that produces permutations in an order where each is only one element swap apart, including swapping back to the original state with one swap at the end. Unify the seldomly used functions `build`, `build_sized`, `build_sized_opt` into just one function `build`. Remove `equal_sizes`
2013-09-10std::at_vec and vec: Unify build_sized, build_sized_opt into buildblake2-ppc-81/+17
These functions have very few users since they are mostly replaced by iterator-based constructions. Convert a few remaining users in-tree, and reduce the number of functions by basically renaming build_sized_opt to build, and removing the other two. This for both the vec and the at_vec versions.
2013-09-10std::vec: Remove the function same_lengthblake2-ppc-5/+0
The basic construct x.len() == y.len() is just as simple. This function used to be a precondition (not sure about the terminology), so it had to be a function. This is not relevant any more.
2013-09-10std::vec: Update module doc textblake2-ppc-19/+60
Update for a lot of changes (not many free functions left), add examples of the important methods `slice` and `push`, and write a short bit about iteration.
2013-09-10std::vec: Replace each_permutation with a new Permutations iteratorblake2-ppc-119/+165
Introduce ElementSwaps and Permutations. ElementSwaps is an iterator that for a given sequence length yields the element swaps needed to visit each possible permutation of the sequence in turn. We use an algorithm that generates a sequence such that each permutation is only one swap apart. let mut v = [1, 2, 3]; for perm in v.permutations_iter() { // yields 1 2 3 | 1 3 2 | 3 1 2 | 3 2 1 | 2 3 1 | 2 1 3 } The `.permutations_iter()` yields clones of the input vector for each permutation. If a copyless traversal is needed, it can be constructed with `ElementSwaps`: for (a, b) in ElementSwaps::new(3) { // yields (2, 1), (1, 0), (2, 1) ... v.swap(a, b); // .. }
2013-09-10std::vec: Change fn unzip to take an iterator argumentblake2-ppc-31/+13
Remove unzip_slice since it's redundant. Old unzip is equivalent to the `|x| unzip(x.move_iter())`
2013-09-07auto merge of #8906 : novalis/rust/master, r=alexcrichtonbors-46/+145
This is a patch to fix #6031. I didn't see any tests for the C++ library code, so I didn't write a test for my changes. Did I miss something, or are there really no tests?
2013-09-07auto merge of #9032 : alexcrichton/rust/inline-repr, r=thestingerbors-0/+1
This allows cross-crate inlining which is *very* good because this is called a lot throughout libstd (even when libstd is inlined across crates). In one of my projects, I have a test case with the following performance characteristics commit | optimization level | runtime (seconds) ----|------|---- before | O2 | 22s before | O3 | 107s after | O2 | 13s after | O3 | 12s I'm a bit disturbed by the 107s runtime from O3 before this commit. The performance characteristics of this test involve doing an absurd amount of small operations. A huge portion of this is creating hashmaps which involves allocating vectors. The worst portions of the profile are: ![screen shot 2013-09-06 at 10 32 15 pm](https://f.cloud.github.com/assets/64996/1100723/e5e8744c-177e-11e3-83fc-ddc5f18c60f9.png) Which as you can see looks like some *serious* problems with inlining. I would expect the hash map methods to be high up in the profile, but the top 9 callers of `cast::transmute_copy` were `Repr::repr`'s various monomorphized instances. I wish there we a better way to detect things like this in the future, and it's unfortunate that this is required for performance in the first place. I suppose I'm not entirely sure why this is needed because all of the methods should have been generated in-crate (monomorphized versions of library functions), so they should have gotten inlined? It also could just be that by modifying LLVM's idea of the inline cost of this function it was able to inline it in many more locations.
2013-09-07Handle global log levels (fixes #6033)novalis-36/+100
2013-09-06auto merge of #9026 : jbclements/rust/let-var-hygiene, r=jbclementsbors-0/+10
This is a rebase of my approved pull request from ... the end of June? It introduces hygiene for let-bound variables.
2013-09-06Flag the Repr::repr function with #[inline]Alex Crichton-0/+1
This allows cross-crate inlining which is *very* good because this is called a lot throughout libstd (even when libstd is inlined across crates).