about summary refs log tree commit diff
path: root/src/libcore/slice.rs
AgeCommit message (Collapse)AuthorLines
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-3/+58
2014-08-26Rebasing changesNick Cameron-0/+21
2014-08-26DST coercions and DST structsNick Cameron-1/+0
[breaking-change] 1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code. 2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible. 3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-1/+1
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-13Address some review feedbackBrian Anderson-14/+12
2014-08-13core: Put stability attributes all over the slice moduleBrian Anderson-0/+72
Much of this is as discussed[1]. Many things are marked [1]: https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md
2014-08-13core: Add binary_search and binary_search_elem methods to slices.Brian Anderson-0/+92
These are like the existing bsearch methods but if the search fails, it returns the next insertion point. The new `binary_search` returns a `BinarySearchResult` that is either `Found` or `NotFound`. For convenience, the `found` and `not_found` methods convert to `Option`, ala `Result`. Deprecate bsearch and bsearch_elem.
2014-08-13core: Rename ImmutableEqSlice to ImmutablePartialEqSliceBrian Anderson-2/+2
This is in the prelude and won't break much code. [breaking-change]
2014-08-13core: Rename MutableCloneableSlice::copy_from to clone_from_sliceBrian Anderson-2/+8
Deprecate the previous.
2014-08-13core: Deprecate ImmutableSlice::tailn and initnBrian Anderson-0/+4
These are equivalent to slice_from and slice_to.
2014-08-13core: Rename ImmutableSlice::unsafe_ref to unsafe_getBrian Anderson-0/+12
Deprecate the previous.
2014-08-13std: Rename slice::Vector to SliceBrian Anderson-12/+14
This required some contortions because importing both raw::Slice and slice::Slice makes rustc crash. Since `Slice` is in the prelude, this renaming is unlikely to casue breakage. [breaking-change]
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-12/+12
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-01Add a split_at method to slice::ImmutableVectornham-4/+17
This method is similar to the mut_split_at method of slice::MutableVector.
2014-07-05libcore: Fix Items iterator for zero sized types.Luqman Aden-12/+24
2014-06-30core: Remove the unnecessary 'traits' module from 'slice'Brian Anderson-49/+39
This is only breaking for code that references the empty `slice::traits` module. [breaking-change]
2014-06-30core: Reorganize slice module.Brian Anderson-458/+514
This is just moving things around so they are defined in a logical order.
2014-06-29Implement RFC#28: Add PartialOrd::partial_cmpSteven Fackler-0/+6
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. RFC: 0028-partial-cmp
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-4/+0
Libcore's test infrastructure is complicated by the fact that many lang items are defined in the crate. The current approach (realcore/realstd imports) is hacky and hard to work with (tests inside of core::cmp haven't been run for months!). Moving tests to a separate crate does mean that they can only test the public API of libcore, but I don't feel that that is too much of an issue. The only tests that I had to get rid of were some checking the various numeric formatters, but those are also exercised through normal format! calls in other tests.
2014-06-28Rename all raw pointers as necessaryAlex Crichton-14/+14
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-13/+13
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-13added get_mut() for [T]bachm-0/+8
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-48/+1
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-5/+5
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-06-06Rename Iterator::len to countAaron Turon-2/+1
This commit carries out the request from issue #14678: > The method `Iterator::len()` is surprising, as all the other uses of > `len()` do not consume the value. `len()` would make more sense to be > called `count()`, but that would collide with the current > `Iterator::count(|T| -> bool) -> unit` method. That method, however, is > a bit redundant, and can be easily replaced with > `iter.filter(|x| x < 5).count()`. > After this change, we could then define the `len()` method > on `iter::ExactSize`. Closes #14678. [breaking-change]
2014-06-06Fix documentation for `slice()`Adolfo OchagavĂ­a-2/+2
Fixes https://github.com/mozilla/rust/issues/14577
2014-06-04core: Apply stability attributes to ptr modBrian Anderson-1/+2
* null and mut_null are unstable. Their names may change if the unsafe pointer types change. * copy_memory and copy_overlapping_memory are unstable. We think they aren't going to change. * set_memory and zero_memory are experimental. Both the names and the semantics are under question. * swap and replace are unstable and probably won't change. * read is unstable, probably won't change * read_and_zero is experimental. It's necessity is in doubt. * mem::overwrite is now called ptr::write to match read and is unstable. mem::overwrite is now deprecated * array_each, array_each_with_len, buf_len, and position are all deprecated because they use old style iteration and their utility is generally under question.
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-9/+9
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-31rustdoc: Create anchor pages for primitive typesAlex Crichton-0/+2
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]` attribute. This attribute indicates that the current module is the "owner" of the primitive type `foo`. For rustdoc, this means that the doc-comment for the module is the doc-comment for the primitive type, plus a signal to all downstream crates that hyperlinks for primitive types will be directed at the crate containing the `#[doc]` directive. Additionally, rustdoc will favor crates closest to the one being documented which "implements the primitive type". For example, documentation of libcore links to libcore for primitive types, but documentation for libstd and beyond all links to libstd for primitive types. This change involves no compiler modifications, it is purely a rustdoc change. The landing pages for the primitive types primarily serve to show a list of implemented traits for the primitive type itself. The primitive types documented includes both strings and slices in a semi-ad-hoc way, but in a way that should provide at least somewhat meaningful documentation. Closes #14474
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-11/+11
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-27Move std::{reflect,repr,Poly} to a libdebug crateAlex Crichton-2/+2
This commit moves reflection (as well as the {:?} format modifier) to a new libdebug crate, all of which is marked experimental. This is a breaking change because it now requires the debug crate to be explicitly linked if the :? format qualifier is used. This means that any code using this feature will have to add `extern crate debug;` to the top of the crate. Any code relying on reflection will also need to do this. Closes #12019 [breaking-change]
2014-05-27std: Remove String's to_ownedRicho Healey-7/+7
2014-05-22Remove a slew of old deprecated functionsAlex Crichton-35/+0
2014-05-20core: Stabilize the mem moduleAlex Crichton-2/+3
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-12libcore: remove fails from slice.rs and remove duplicated length checkingKevin Butler-24/+35
core::slice::raw::{shift_ptr,pop_ptr} now returns Option<*T> rather than *T. They no longer fail on empty slices. [breaking-change]
2014-05-11core: Remove the cast moduleAlex Crichton-4/+3
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-07core: Inherit non-allocating slice functionalityAlex Crichton-0/+1483
This commit adds a new trait, MutableVectorAllocating, which represents functions on vectors which can allocate. This is another extension trait to slices which should be removed once a lang item exists for the ~ allocation.