about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2014-05-21Add examples for edge cases of str.split/str.splitnTobias Bucher-0/+9
In particular, show examples for splitting the empty string and using `splitn` with a count of 0. Fix #14222.
2014-05-21auto merge of #14316 : kballard/rust/range_inclusive_no_toprimitive, ↵bors-1/+1
r=alexcrichton
2014-05-20auto merge of #14259 : alexcrichton/rust/core-mem, r=brsonbors-73/+148
Excluding the functions inherited from the cast module last week (with marked stability levels), these functions received the following treatment. * size_of - this method has become #[stable] * nonzero_size_of/nonzero_size_of_val - these methods have been removed * min_align_of - this method is now #[stable] * pref_align_of - this method has been renamed without the `pref_` prefix, and it is the "default alignment" now. This decision is in line with what clang does (see url linked in comment on function). This function is now #[stable]. * init - renamed to zeroed and marked #[stable] * uninit - marked #[stable] * move_val_init - renamed to overwrite and marked #[stable] * {from,to}_{be,le}{16,32,64} - all functions marked #[stable] * swap/replace/drop - marked #[stable] * size_of_val/min_align_of_val/align_of_val - these functions are marked #[unstable], but will continue to exist in some form. Concerns have been raised about their `_val` prefix.
2014-05-20core: Stabilize the mem moduleAlex Crichton-73/+148
Excluding the functions inherited from the cast module last week (with marked stability levels), these functions received the following treatment. * size_of - this method has become #[stable] * nonzero_size_of/nonzero_size_of_val - these methods have been removed * min_align_of - this method is now #[stable] * pref_align_of - this method has been renamed without the `pref_` prefix, and it is the "default alignment" now. This decision is in line with what clang does (see url linked in comment on function). This function is now #[stable]. * init - renamed to zeroed and marked #[stable] * uninit - marked #[stable] * move_val_init - renamed to overwrite and marked #[stable] * {from,to}_{be,le}{16,32,64} - all functions marked #[stable] * swap/replace/drop - marked #[stable] * size_of_val/min_align_of_val/align_of_val - these functions are marked #[unstable], but will continue to exist in some form. Concerns have been raised about their `_val` prefix. [breaking-change]
2014-05-20auto merge of #14293 : alexcrichton/rust/weak-lang-items, r=brsonbors-5/+14
This commit is part of the ongoing libstd facade efforts (cc #13851). The compiler now recognizes some language items as "extern { fn foo(...); }" and will automatically perform the following actions: 1. The foreign function has a pre-defined name. 2. The crate and downstream crates can only be built as rlibs until a crate defines the lang item itself. 3. The actual lang item has a pre-defined name. This is essentially nicer compiler support for the hokey core-depends-on-std-failure scheme today, but it is implemented the same way. The details are a little more hidden under the covers. In addition to failure, this commit promotes the eh_personality and rust_stack_exhausted functions to official lang items. The compiler can generate calls to these functions, causing linkage errors if they are left undefined. The checking for these items is not as precise as it could be. Crates compiling with `-Z no-landing-pads` will not need the eh_personality lang item, and crates compiling with no split stacks won't need the stack exhausted lang item. For ease, however, these items are checked for presence in all final outputs of the compiler. It is quite easy to define dummy versions of the functions necessary: #[lang = "stack_exhausted"] extern fn stack_exhausted() { /* ... */ } #[lang = "eh_personality"] extern fn eh_personality() { /* ... */ } cc #11922, rust_stack_exhausted is now a lang item cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-20Remove useless ToPrimitive bound on range_inclusive()Kevin Ballard-1/+1
2014-05-20Address review commentsBrian Anderson-6/+6
2014-05-20core: Convert TODOs to FIXMEsBrian Anderson-5/+5
2014-05-20core: Spruce up the crate descriptionBrian Anderson-11/+22
2014-05-20core: More concise description for mod opsBrian Anderson-1/+1
2014-05-20core: Improve docs for cellBrian Anderson-1/+151
2014-05-19auto merge of #14289 : TyOverby/rust/master, r=alexcrichtonbors-8/+18
Closes #14278. Previously the type signatures of the ordering functions in `core::iter::order` took two iterators, but only if they were the same type of iterator. This commit loosens that restriction and allows different kinds of iterators (but with the same type of elements) to be compared.
2014-05-19core::iter::order functions now take two types of iterators.TyOverby-8/+18
Previously the type signatures of the ordering functions in `core::iter::order` took two iterators, but only if they were the same type of iterator. This commit loosens that restriction and allows different kinds of iterators (but with the same type of elements) to be compared.
2014-05-19auto merge of #14294 : kballard/rust/result_unwrap_or_else, r=alexcrichtonbors-4/+11
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else(). In the interests of naming consistency, call it the same thing. [breaking-change]
2014-05-19Rename Result.unwrap_or_handle() to .unwrap_or_else()Kevin Ballard-4/+11
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else(). In the interests of naming consistency, call it the same thing. [breaking-change]
2014-05-19auto merge of #14292 : limeburst/rust/master, r=alexcrichtonbors-1/+1
2014-05-19rustc: Add official support for weak failureAlex Crichton-5/+14
This commit is part of the ongoing libstd facade efforts (cc #13851). The compiler now recognizes some language items as "extern { fn foo(...); }" and will automatically perform the following actions: 1. The foreign function has a pre-defined name. 2. The crate and downstream crates can only be built as rlibs until a crate defines the lang item itself. 3. The actual lang item has a pre-defined name. This is essentially nicer compiler support for the hokey core-depends-on-std-failure scheme today, but it is implemented the same way. The details are a little more hidden under the covers. In addition to failure, this commit promotes the eh_personality and rust_stack_exhausted functions to official lang items. The compiler can generate calls to these functions, causing linkage errors if they are left undefined. The checking for these items is not as precise as it could be. Crates compiling with `-Z no-landing-pads` will not need the eh_personality lang item, and crates compiling with no split stacks won't need the stack exhausted lang item. For ease, however, these items are checked for presence in all final outputs of the compiler. It is quite easy to define dummy versions of the functions necessary: #[lang = "stack_exhausted"] extern fn stack_exhausted() { /* ... */ } #[lang = "eh_personality"] extern fn eh_personality() { /* ... */ } cc #11922, rust_stack_exhausted is now a lang item cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-20Fix typo in libcoreJihyeok Seo-1/+1
2014-05-19Minor doc fixes in various placesPiotr Jawniak-18/+25
2014-05-18auto merge of #14276 : aochagavia/rust/pr, r=alexcrichtonbors-2/+2
2014-05-18Removed unnecessary transmuteAdolfo Ochagavía-2/+2
2014-05-18auto merge of #14258 : alexcrichton/rust/dox-format-writer, r=cmrbors-4/+32
This commit fills in the documentation holes for the FormatWriter trait which were previously accidentally left blank. Additionally, this adds the `write_fmt` method to the trait to allow usage of the `write!` macro with implementors of the `FormatWriter` trait. This is not useful for consumers of the standard library who should generally avoid the `FormatWriter` trait, but it is useful for consumers of the core library who are not using the standard library.
2014-05-17auto merge of #14249 : alexcrichton/rust/issue-14246, r=huonwbors-1/+17
Closes #14246
2014-05-17core: Document FormatWriter and allow `write!`Alex Crichton-4/+32
This commit fills in the documentation holes for the FormatWriter trait which were previously accidentally left blank. Additionally, this adds the `write_fmt` method to the trait to allow usage of the `write!` macro with implementors of the `FormatWriter` trait. This is not useful for consumers of the standard library who should generally avoid the `FormatWriter` trait, but it is useful for consumers of the core library who are not using the standard library.
2014-05-17core: Clarify the documentation on core's preludeAlex Crichton-1/+17
Closes #14246
2014-05-17Register new snapshotsAlex Crichton-4/+0
2014-05-16auto merge of #14135 : gereeter/rust/two-way-search, r=brsonbors-26/+206
This changes the previously naive string searching algorithm to a two-way search like glibc, which should be faster on average while still maintaining worst case linear time complexity. This fixes #14107. Note that I don't think this should be merged yet, as this is the only approach to speeding up search I've tried - it's worth considering options like Boyer-Moore or adding a bad character shift table to this. However, the benchmarks look quite good so far: test str::bench::bench_contains_bad_naive ... bench: 290 ns/iter (+/- 12) from 1309 ns/iter (+/- 36) test str::bench::bench_contains_equal ... bench: 479 ns/iter (+/- 10) from 137 ns/iter (+/- 2) test str::bench::bench_contains_short_long ... bench: 2844 ns/iter (+/- 105) from 5473 ns/iter (+/- 14) test str::bench::bench_contains_short_short ... bench: 55 ns/iter (+/- 4) from 57 ns/iter (+/- 6) Except for the case specifically designed to be optimal for the naive case (`bench_contains_equal`), this gets as good or better performance as the previous code.
2014-05-15core: Update all tests for fmt movementAlex Crichton-132/+219
2014-05-15std: Fix float testsAlex Crichton-27/+1
2014-05-15core: Implement f32/f64 formattingAlex Crichton-0/+362
This is a migration of the std::{f32, f64}::to_str* functionality to the core library. This removes the growable `Vec` used in favor of a large stack buffer. The maximum base 10 exponent for f64 is 308, so a stack buffer of 512 bytes should be sufficient to store all floats.
2014-05-15Updates with core::fmt changesAlex Crichton-1/+1
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15core: Derive Show impls wherever possibleAlex Crichton-6/+6
These were temporarily moved to explicit implementations, but now that fmt is in core it's possible to derive again.
2014-05-15core: Implement and export the try! macroAlex Crichton-0/+6
This is used quite extensively by core::fmt
2014-05-15core: Allow formatted failure and assert in coreAlex Crichton-2/+25
With std::fmt having migrated, the failure macro can be expressed in its full glory.
2014-05-15core: Implement unwrap()/unwrap_err() on ResultAlex Crichton-18/+61
Now that std::fmt is in libcore, it's possible to implement this as an inherit method rather than through extension traits. This commit also tweaks the failure interface of libcore to libstd to what it should be, one method taking &fmt::Arguments
2014-05-15core: Inherit the std::fmt moduleAlex Crichton-0/+1407
This commit moves all possible functionality from the standard library's string formatting utilities into the core library. This is a breaking change, due to a few tweaks in the semantics of formatting: 1. In order to break the dependency on the std::io module, a new trait, FormatWriter was introduced in core::fmt. This is the trait which is used (instead of Writer) to format data into a stream. 2. The new FormatWriter trait has one method, write(), which takes some bytes and can return an error, but the error contains very little information. The intent for this trait is for an adaptor writer to be used around the standard library's Writer trait. 3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but rather &mut FormatWriter. Since this trait is less common, all functions were removed except fmt::write, and it is not intended to be invoked directly. The main API-breaking change here is that the fmt::Formatter structure will no longer expose its `buf` field. All previous code writing directly to `f.buf` using writer methods or the `write!` macro will now instead use `f` directly. The Formatter object itself implements the `Writer` trait itself for convenience, although it does not implement the `FormatWriter` trait. The fallout of these changes will be in the following commits. [breaking-change]
2014-05-15core: Move intrinsic float functionality from stdAlex Crichton-2/+699
The Float trait in libstd is quite a large trait which has dependencies on cmath (libm) and such, which libcore cannot satisfy. It also has many functions that libcore can implement, however, as LLVM has intrinsics or they're just bit twiddling. This commit moves what it can of the Float trait from the standard library into libcore to allow floats to be usable in the core library. The remaining functions are now resident in a FloatMath trait in the standard library (in the prelude now). Previous code which was generic over just the Float trait may now need to be generic over the FloatMath trait. [breaking-change]
2014-05-15Implement cell::clone_refKeegan McAllister-0/+34
Per discussion with @alexcrichton, this is a free function.
2014-05-15core: Remove the unit moduleBrian Anderson-47/+22
2014-05-15Add a crate for missing stubs from libcoreAlex Crichton-0/+3
The core library in theory has 0 dependencies, but in practice it has some in order for it to be efficient. These dependencies are in the form of the basic memory operations provided by libc traditionally, such as memset, memcmp, etc. These functions are trivial to implement and themselves have 0 dependencies. This commit adds a new crate, librlibc, which will serve the purpose of providing these dependencies. The crate is never linked to by default, but is available to be linked to by downstream consumers. Normally these functions are provided by the system libc, but in other freestanding contexts a libc may not be available. In these cases, librlibc will suffice for enabling execution with libcore. cc #10116
2014-05-15Register new snapshotsAlex Crichton-104/+0
2014-05-14auto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichtonbors-1/+33
Also Show, which is useful in assertions. Fixes #14074
2014-05-14Switched to the two-way algorithm for string searchingJonathan S-26/+206
test str::bench::bench_contains_bad_naive ... bench: 300 ns/iter (+/- 12) from 1309 ns/iter (+/- 36) test str::bench::bench_contains_equal ... bench: 154 ns/iter (+/- 7) from 137 ns/iter (+/- 2) test str::bench::bench_contains_short_long ... bench: 2998 ns/iter (+/- 74) from 5473 ns/iter (+/- 14) test str::bench::bench_contains_short_short ... bench: 65 ns/iter (+/- 2) from 57 ns/iter (+/- 6)
2014-05-14define Eq,TotalEq,Ord,TotalOrd for &mut TDaniel Brooks-1/+33
Also Show, which is useful in assertions. Fixes #14074
2014-05-13core: Allow using failure outside of libcoreAlex Crichton-4/+7
Due to our excellent macro hygiene, this involves having a global path and a hidden module in libcore itself.
2014-05-13core: Document should_not_exist's existenceAlex Crichton-0/+16
Explain why it should not exist, and the plan of attack for removing it.
2014-05-13core: Add a crate doc blockAlex Crichton-0/+21
2014-05-13core: Inherit the atomics moduleAlex Crichton-0/+792
2014-05-13io: Implement process wait timeoutsAlex Crichton-0/+1
This implements set_timeout() for std::io::Process which will affect wait() operations on the process. This follows the same pattern as the rest of the timeouts emerging in std::io::net. The implementation was super easy for everything except libnative on unix (backwards from usual!), which required a good bit of signal handling. There's a doc comment explaining the strategy in libnative. Internally, this also required refactoring the "helper thread" implementation used by libnative to allow for an extra helper thread (not just the timer). This is a breaking change in terms of the io::Process API. It is now possible for wait() to fail, and subsequently wait_with_output(). These two functions now return IoResult<T> due to the fact that they can time out. Additionally, the wait_with_output() function has moved from taking `&mut self` to taking `self`. If a timeout occurs while waiting with output, the semantics are undesirable in almost all cases if attempting to re-wait on the process. Equivalent functionality can still be achieved by dealing with the output handles manually. [breaking-change] cc #13523
2014-05-13std: Rename str::Normalizations to str::DecompositionsFlorian Zeitz-3/+3
The Normalizations iterator has been renamed to Decompositions. It does not currently include all forms of Unicode normalization, but only encompasses decompositions. If implemented recomposition would likely be a separate iterator which works on the result of this one. [breaking-change]