| Age | Commit message (Collapse) | Author | Lines |
|
Also re-add the previously deleted test with an additional test that would have
failed before, when the hash function depended on the capacity.
|
|
Strings iterate to both char and &str, so it is natural it can also be extended or collected from an iterator of &str.
Apart from the trait implementations, `Extend<char>` is updated to use the iterator size hint, and the test added tests both the char and the &str versions of Extend and FromIterator.
|
|
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
|
|
I'm interested in including doctests for `BTreeMap`'s `iter_mut` and `into_iter` methods in this PR as well, but I am not sure of the best way to demonstrate/test what they do for the doctests.
|
|
- Introduce a named type for the return type of `VecMap::move_iter`
- Rename all type parameters to `V` for "Value".
- Remove unnecessary call to an `Option::unwrap`, use pattern matching instead.
- Remove incorrect `Hash` implementation which took the `VecMap`'s capacity
into account.
This is a [breaking-change], however whoever used the `Hash` implementation
relied on an incorrect implementation.
|
|
Change Example to Examples.
Add a doctest that better demonstrates the utility of as_string.
Update the doctest example to use String instead of &String.
|
|
|
|
|
|
This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.
A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.
For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.
This breaks code like:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
Change this code to:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
impl Copy for Point2D {}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
This is the backwards-incompatible part of #13231.
Part of RFC #3.
[breaking-change]
|
|
(I don't understand why this works, and so I don't quite trust this yet. I'm pushing it up to see if anyone else can replicate this performance increase)
Somehow llvm is able to optimize this version of Vec::reserve into dramatically faster than the old version. In micro-benchmarks this was 2-10 times faster. It also reduce my Rust compile time from 41 minutes to 27 minutes.
Closes #19281.
|
|
Fixes #19269.
/cc @thestinger @mahkoh @mitsuhiko
|
|
jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r=Gankro
|
|
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns:
- `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")`
- `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")`
- `vec.as_mut_slice().sort()` -> `vec.sort()`
- `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)`
---
Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation.
This is rebased on top of #19167
cc @alexcrichton @aturon
|
|
Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TreeSet. The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).
r? @Gankro
|
|
|
|
|
|
&str is a "particle" of a string already, see the graphemes iterator,
so it seems natural that we should be able to use it with Extend.
|
|
|
|
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
|
|
There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs.
Someone on IRC said, *Write doctests!*, so here I am.
I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.
|
|
|
|
|
|
|
|
|
|
|
|
In regards to:
https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729
This commit:
* Changes the #deriving code so that it generates code that utilizes fewer
reexports (in particur Option::* and Result::*), which is necessary to
remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
|
|
Add a rustdoc test for union to exhibit how it is used.
There is already a test for union in the test namespace, but this commit
adds a doctest that will appear in the rustdocs.
Add a doctest for the difference function.
Add a doctest for the symmetric_difference function.
Add a doctest for the intersection function.
Update the union et al. doctests based on @Gankro's comments.
Make the union et al. doctests a bit more readable.
|
|
Update keys() and values() for BTreeMap based on @Gankro's comments.
Assign keys and values to variables before doing assertion.
|
|
Somehow llvm is able to optimize this version of Vec::reserve
into dramatically faster than the old version. In micro-benchmarks
this was 2-10 times faster. It also shaved 14 minutes off of
rust's compile times.
Closes #19281.
|
|
Conflicts:
src/libcollections/trie/set.rs
|
|
|
|
Part of #18424
Adds `capacity()` function to VecMap, as per the collections reform.
(Salvaged from #19516, #19523, while we await an RFC regarding `reserve`/`reserve_index` for `VecMap`)
|
|
Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TrieSet. The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).
|
|
|
|
Changed capacity() tag to unstable and fixed doc assert
|
|
|
|
|
|
- String == &str == CowString
- Vec == &[T] == &mut [T] == [T, ..N] == CowVec
- InternedString == &str
|
|
pop calls siftdown, siftdown calls siftdown_range, and siftdown_range
loops on an index that can start as low as 0 and approximately doubles
each iteration.
|
|
|
|
This implementation existed on MaybeOwned, but has been lost in the
transition to Cows. Let's put it back.
|
|
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
|
|
|
|
|
|
Sister pull request of https://github.com/rust-lang/rust/pull/19288, but
for the other style of block doc comment.
|
|
There's no reason that BinaryHeap's iterator can't implement DoubleEnded and ExactSize, so add these implementations.
|
|
Closes #19305
|
|
TrieSet doesn't yet have union, intersection, difference, and symmetric difference functions implemented. Luckily, TrieSet is largely similar to TreeSet, so I was able to reference the implementations of these functions in the latter, and adapt them as necessary to make them work for TrieSet.
One thing that I thought was interesting is that the Iterator yielded by `iter()` for TrieSet iterates over the set's values directly rather than references to the values (whereas I think in most cases I see the Iterator given by `iter()` iterating over immutable references), so for consistency within TrieSet's interface, all of these Iterators also iterate over the values directly. Let me know if all of these should be instead iterating over references.
|
|
This is considered good convention.
This is about half of them in total, I just don't want an impossible to land patch. :smile:
|
|
At the same time remove the `pub use` of the variants in favor of accessing
through the enum type itself. This is a breaking change as the `Found` and
`NotFound` variants must now be imported through `BinarySearchResult` instead of
just `std::slice`.
[breaking-change]
Closes #19271
|