about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2014-11-20Rename remaining Failures to PanicSubhash Bhushan-2/+2
2014-11-20Implement BorrowFrom<&'a T> for T (with mutable variants)Jonathan S-2/+10
2014-11-20Add Utf16Encoder. Generalize Utf16CodeUnits for any Iterator<char>.Simon Sapin-3/+25
This allows encoding to UTF-16 something that is not in UTF-8, e.g. a `[char]` UTF-32 string. This might help with https://github.com/servo/servo/issues/4023
2014-11-20Add comment on why `RefCell::unwrap` is safeTobias Bucher-0/+3
2014-11-20libcore: DSTify ops traits, EquivAaron Turon-20/+20
This commit relaxes constraints on generics and traits within the `core::ops` module and for the `Equiv` trait.
2014-11-20libcore: DST-ify AsSliceAaron Turon-5/+15
This commit changes `AsSlice` to work on unsized types, and changes the `impl` for `&[T]` to `[T]`. Aside from making the trait more general, this also helps some ongoing work with method resolution changes. This is a breaking change: code that uses generics bounded by `AsSlice` will have to change. In particular, such code previously often took arguments of type `V` where `V: AsSlice<T>` by value. These should now be taken by reference: ```rust fn foo<Sized? V: AsSlice<T>>(v: &V) { .. } ``` A few std lib functions have been changed accordingly. [breaking-change]
2014-11-20Removed unneeded conversion to a slice.Davis Silverman-1/+0
Vec<T> can index now so its a useless conversion.
2014-11-20auto merge of #18999 : aturon/rust/stab-floats, r=alexcrichton,alexcrichtonbors-30/+102
This commit adds stability markers for the APIs that have recently been aligned with [numerics reform](https://github.com/rust-lang/rfcs/pull/369). For APIs that were changed as part of that reform, `#[unstable]` is used to reflect the recency, but the APIs will become `#[stable]` in a follow-up pass. In addition, a few aspects of the APIs not explicitly covered by the RFC are marked here -- in particular, constants for floats. This commit does not mark the `uint` or `int` modules as `#[stable]`, given the ongoing debate out the names and roles of these types. Due to some deprecation (see the RFC for details), this is a: [breaking-change] r? @alexcrichton cc @bjz
2014-11-19rollup merge of #19108: steveklabnik/doc_atomic_boolJakub Bukaj-98/+296
I don't know enough about the free functions to give them better docs right now.
2014-11-19rollup merge of #19040: alexcrichton/issue-18904Jakub Bukaj-95/+76
This commit applies the stabilization of std::fmt as outlined in [RFC 380][rfc]. There are a number of breaking changes as a part of this commit which will need to be handled to migrated old code: * A number of formatting traits have been removed: String, Bool, Char, Unsigned, Signed, and Float. It is recommended to instead use Show wherever possible or to use adaptor structs to implement other methods of formatting. * The format specifier for Boolean has changed from `t` to `b`. * The enum `FormatError` has been renamed to `Error` as well as becoming a unit struct instead of an enum. The `WriteError` variant no longer exists. * The `format_args_method!` macro has been removed with no replacement. Alter code to use the `format_args!` macro instead. * The public fields of a `Formatter` have become read-only with no replacement. Use a new formatting string to alter the formatting flags in combination with the `write!` macro. The fields can be accessed through accessor methods on the `Formatter` structure. Other than these breaking changes, the contents of std::fmt should now also all contain stability markers. Most of them are still #[unstable] or #[experimental] [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0380-stabilize-std-fmt.md [breaking-change] Closes #18904
2014-11-19rollup merge of #18903: steveklabnik/error_handling_guideJakub Bukaj-46/+0
Now that we've done `fail` -> `panic`, I feel bringing back the error handling guide is a good idea. We had one long ago, but it was removed when conditions were removed. This doesn't cover the new FromError stuff, but I feel like it's already useful in this state, so I'm sending this PR now.
2014-11-19Document almost all of atomics.Steve Klabnik-98/+296
I don't know enough about the free functions to give them better docs right now.
2014-11-18std: Stabilize std::fmtAlex Crichton-95/+76
This commit applies the stabilization of std::fmt as outlined in [RFC 380][rfc]. There are a number of breaking changes as a part of this commit which will need to be handled to migrated old code: * A number of formatting traits have been removed: String, Bool, Char, Unsigned, Signed, and Float. It is recommended to instead use Show wherever possible or to use adaptor structs to implement other methods of formatting. * The format specifier for Boolean has changed from `t` to `b`. * The enum `FormatError` has been renamed to `Error` as well as becoming a unit struct instead of an enum. The `WriteError` variant no longer exists. * The `format_args_method!` macro has been removed with no replacement. Alter code to use the `format_args!` macro instead. * The public fields of a `Formatter` have become read-only with no replacement. Use a new formatting string to alter the formatting flags in combination with the `write!` macro. The fields can be accessed through accessor methods on the `Formatter` structure. Other than these breaking changes, the contents of std::fmt should now also all contain stability markers. Most of them are still #[unstable] or #[experimental] [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0380-stabilize-std-fmt.md [breaking-change] Closes #18904
2014-11-18Fallout from deprecationAaron Turon-7/+9
2014-11-18libs: stabilize most numerics after RFC changesAaron Turon-23/+93
This commit adds stability markers for the APIs that have recently been aligned with [numerics reform](https://github.com/rust-lang/rfcs/pull/369). For APIs that were changed as part of that reform, `#[unstable]` is used to reflect the recency, but the APIs will become `#[stable]` in a follow-up pass. In addition, a few aspects of the APIs not explicitly covered by the RFC are marked here -- in particular, constants for floats. This commit does not mark the `uint` or `int` modules as `#[stable]`, given the ongoing debate out the names and roles of these types. Due to some deprecation (see the RFC for details), this is a: [breaking-change]
2014-11-18Error handling guideSteve Klabnik-46/+0
2014-11-18auto merge of #19060 : Gankro/rust/super-cloned, r=aturonbors-4/+45
Edit: whoops, didn't mean to hit post. Anyway, this is something I tried to do when I first implemented cloned, but couldn't figure out. Somewhere between then and the PR actually landing, we got Deref of references, so now this works! :tada: Also turns out the test for the functionality was never marked as a #[test]. Oops! Also added a Cloned iterator adaptor. If this isn't desirable, it can be taken out of the PR (seperate commits).
2014-11-18auto merge of #19031 : nodakai/rust/libcore-pow-and-sq, r=bjzbors-21/+26
[breaking-change] Deprecates `core::num::pow` in favor of `Int::pow`.
2014-11-18add Cloned iterator adaptorAlexis Beingessner-1/+40
2014-11-18make cloned generic over deref... and have its tests actually runAlexis Beingessner-3/+5
2014-11-18libcore: add num::Int::pow() and deprecate num::pow().NODA, Kai-21/+26
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-11-18Fix compilation and tests after the roll-upJakub Bukaj-0/+1
2014-11-18rollup merge of #19041: japaric/cloneJakub Bukaj-13/+3
Closes #19037 cc #16918 r? @aturon
2014-11-18rollup merge of #19015: alex/libcore-typosJakub Bukaj-3/+3
2014-11-18rollup merge of #18951: tbu-/pr_array_cloneshowJakub Bukaj-8/+22
Due to not being able to parametrize over array sizes, `Clone` is only implemented for element types that are `Copy`able.
2014-11-18rollup merge of #18911: canndrew/slice_shift_charJakub Bukaj-20/+20
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This PR changes `slice_shift_char` so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None
2014-11-17DSTify `impl Clone for &T`Jorge Aparicio-13/+3
Closes #19037
2014-11-17Further DSTify Index traitsAaron Turon-2/+2
2014-11-17libcore: add borrow moduleAaron Turon-0/+127
Following [the collections reform RFC](https://github.com/rust-lang/rfcs/pull/235), this commit adds a new `borrow` module to libcore. The module contains traits for borrowing data (`BorrowFrom` and `BorrowFromMut`), generalized cloning (`ToOwned`), and a clone-on-write smartpointer (`Cow`).
2014-11-17auto merge of #18973 : sfackler/rust/enum-namespace-pt2, r=pcwaltonbors-15/+46
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17Switch to purely namespaced enumsSteven Fackler-15/+46
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17auto merge of #19007 : huonw/rust/more-marker-impls, r=alexcrichtonbors-10/+10
Useful for #[deriving].
2014-11-17auto merge of #19027 : nick29581/rust/coercions-4, r=alexcrichtonbors-16/+16
The forwards compatible parts of #18645, rebased. Converts implicit coercions from `[T, ..n]` to `&[T]` into explicit references.
2014-11-17Fix fallout from coercion removalNick Cameron-16/+16
2014-11-17change return type of slice_shift_charAndrew Cann-20/+20
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This commit changes slice_shift_char so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None [breaking-change]
2014-11-17auto merge of #18914 : Gankro/rust/cloned, r=aturonbors-0/+9
Part of #18424. r? @aturon [breaking-change]
2014-11-17auto merge of #18927 : areski/rust/pr-improve-option-match-readl, r=jakub-bors-5/+20
**match** are much more easy to read when it's not in 1 single line
2014-11-16Fixed a few typos in libcoreAlex Gaynor-3/+3
2014-11-17Implement more basic traits for the marker types.Huon Wilson-10/+10
2014-11-16implement cloned for OptionAlexis Beingessner-0/+9
2014-11-16rollup merge of #18976: bjz/rfc369-numericsJakub Bukaj-5/+343
2014-11-16rollup merge of #18970: aturon/fixup-stableJakub Bukaj-11/+61
2014-11-16rollup merge of #18960: stepancheg/cell-defaultJakub Bukaj-0/+15
2014-11-16Remove core::num::strconvBrendan Zabarauskas-411/+282
2014-11-16Move FromStr to core::strBrendan Zabarauskas-2/+469
2014-11-14libs: fix #[stable] inheritance falloutAaron Turon-11/+61
A recent change turned off inheritance for the #[stable] by default, but failed to catch all the cases where this was being used in std. This patch fixes that problem.
2014-11-14auto merge of #18894 : ArtemGr/rust/patch-1, r=pnkfelixbors-1/+1
A typo about Results being panics crawled in. Fixing it.
2014-11-14impl Default for Cell and RefCellStepan Koltsov-0/+15
It is necessary to have #[deriving(Default)] for struct containing cells like Cell<u32>.
2014-11-14auto merge of #18880 : barosl/rust/doc-fail-to-panic, r=alexcrichtonbors-65/+65
I found some occurrences of "failure" and "fails" in the documentation. I changed them to "panics" if it means a task panic. Otherwise I left it as is, or changed it to "errors" to clearly distinguish them. Also, I made a minor fix that is breaking the layout of a module page. "Example" is shown in an irrelevant place from the following page: http://doc.rust-lang.org/std/os/index.html
2014-11-14Add `Show` and `Clone` trait to arraysTobias Bucher-8/+22
Due to not being able to parametrize over array sizes, `Clone` is only implemented for element types that are `Copy`able.