Commit Graph

2376 Commits

Author SHA1 Message Date
blake2-ppc
6999b5332f cmp: Use default methods in trait Eq, require only Eq::eq 2013-07-15 13:24:35 +02:00
bors
0cb1ac0f9f auto merge of #7788 : MarkJr94/rust/from_iter, r=cmr
Added Iterators for HashMap/Set, TreeMap/Set, TrieMap/Set, and PriorityQueue as per Issue #7626
2013-07-14 12:01:22 -07:00
=Mark Sinclair
bbe03da9c6 Stripped trailing spaces; Implemented FromIterator for TreeMap and PriorityQueue 2013-07-14 13:18:50 -04:00
Alex Crichton
9fd2ac7428 Make TLS keys actually take up space
If the TLS key is 0-sized, then the linux linker is apparently smart enough to
put everything at the same pointer. OSX on the other hand, will reserve some
space for all of them. To get around this, the TLS key now actuall consumes
space to ensure that it gets a unique pointer
2013-07-14 10:15:07 -07:00
Alex Crichton
e3211fa1f1 Purge the last remnants of the old TLS api
Closes #3273
2013-07-14 09:29:12 -07:00
=Mark Sinclair
bb6615d43a Implemented FromIterator for TrieMap and TrieSet 2013-07-14 12:20:48 -04:00
=Mark Sinclair
4ff7ef434f Implemented FromIterator for std::hashmap 2013-07-14 11:26:03 -04:00
Steven Fackler
6b37b5bab7 Split mutable methods out of Set and Map
Fixes most of #4989. I didn't add Persistent{Set,Map} since the only
persistent data structure is fun_treemap and its functionality is
currently too limited to build a trait out of.
2013-07-13 19:44:36 -07:00
bors
403cdd84a4 auto merge of #7765 : blake2-ppc/rust/ord-default-methods, r=huonw
Rust will allow to supply default methods for all four methods, but we
don't have any nice error reporting for the case where at least one
method must be implemented, but it's arbitrary which.

So in this case, we require `lt`, but allow implementing the others if needed.
2013-07-13 06:01:31 -07:00
bors
d582eeb1ec auto merge of #7734 : alexcrichton/rust/issue-3395, r=sanxiyn
Also ends up fixing one case in libstd. 

Closes #3395
2013-07-12 21:40:36 -07:00
blake2-ppc
36f20423c3 cmp: Use default methods in trait Ord, only require Ord::lt
It will be simpler to implement only one method for Ord, while we also
allow implementing all four Ord methods for semantics or performance
reasons.

We only supply three default methods (and not four), because don't have
any nice error reporting for the case where at least one method must be
implemented, but it's arbitrary which.
2013-07-13 06:23:38 +02:00
bors
1ee54a8617 auto merge of #7725 : msullivan/rust/default-methods, r=pcwalton
r?
2013-07-12 17:28:28 -07:00
bors
96453eb5c5 auto merge of #7736 : thestinger/rust/doc, r=thestinger
2b96408 r=sanxiyn

documents conversion, size hints and double-ended iterators and adds
more of the traits to the prelude
2013-07-12 13:34:29 -07:00
Alex Crichton
9b21bf45e9 Account for possible 0-sized elements in vector iterators
Closes #7733
2013-07-12 16:13:57 -04:00
Alex Crichton
1ec06e0124 Remove the global 'vec::to_owned' function 2013-07-12 16:13:51 -04:00
bors
f67935257b auto merge of #7696 : glinscott/rust/utf8_perf, r=cmr
Moves multibyte code to it's own function to make char_range_at
easier to inline, and faster for single and multibyte chars.

Benchmarked reading example.json 100 times, 1.18s before, 1.08s
after.

Also, optimize str::is_utf8 for the single and multibyte case
Before:
is_utf8_ascii:          272.355162 ms
is_utf8_multibyte:      167.337334 ms

After:
is_utf8_ascii:          218.088049 ms
is_utf8_multibyte:      134.836722 ms
2013-07-12 03:46:41 -07:00
Daniel Micay
2b96408600 extend the iterator tutorial
documents conversion, size hints and double-ended iterators and adds
more of the traits to the prelude
2013-07-12 01:53:50 -04:00
bors
07183ea6e7 auto merge of #7677 : alexcrichton/rust/tls-gc, r=pcwalton
cc #6004 and #3273

This is a rewrite of TLS to get towards not requiring `@` when using task local storage. Most of the rewrite is straightforward, although there are two caveats:

1. Changing `local_set` to not require `@` is blocked on #7673
2. The code in `local_pop` is some of the most unsafe code I've written. A second set of eyes should definitely scrutinize it...

The public-facing interface currently hasn't changed, although it will have to change because `local_data::get` cannot return `Option<T>`, nor can it return `Option<&T>` (the lifetime isn't known). This will have to be changed to be given a closure which yield `&T` (or as an Option). I didn't do this part of the api rewrite in this pull request as I figured that it could wait until when `@` is fully removed.

This also doesn't deal with the issue of using something other than functions as keys, but I'm looking into using static slices (as mentioned in the issues).
2013-07-11 19:52:37 -07:00
Alex Crichton
2cd9d7bc88 Expand ctypes warnings to warn about *int/*uint
Also ends up fixing one case in libstd
2013-07-11 19:45:25 -07:00
Alex Crichton
a15c1b4464 Fix tests 2013-07-11 18:57:19 -07:00
Michael Sullivan
3fa5203273 Take default methods out from behind the flag. 2013-07-11 15:51:10 -07:00
bors
f92b75ac06 auto merge of #7707 : thestinger/rust/double, r=cmr
00da76d r=cmr
6e75f2d r=cmr

This implements the trait for vector iterators, replacing the reverse
iterator types. The methods will stay, for implementing the future
reverse Iterable traits and convenience.

This can also be trivially implemented for circular buffers and other
variants of arrays like strings.

The `DoubleEndedIterator` trait will allow for implementing algorithms
like in-place reverse on generic mutable iterators.

The naming (`Range` vs. `Iterator`, `Bidirectional` vs. `DoubleEnded`)
can be bikeshedded in the future.
2013-07-11 13:28:38 -07:00
Gary Linscott
5aee5a11e3 Optimize is_utf8
Manually unroll the multibyte loops, and optimize for the single
byte chars.
2013-07-11 14:23:15 -04:00
Gary Linscott
179637304a char_range_at perf work
Moves multibyte code to it's own function to make char_range_at
easier to inline, and faster for single and multibyte chars.

Benchmarked reading example.json 100 times, 1.18s before, 1.08s
after.
2013-07-11 14:23:14 -04:00
bors
323ac9931b auto merge of #7708 : bcully/rust/warnings, r=thestinger
Just getting my feet wet.
2013-07-11 05:40:36 -07:00
bors
6ea0c7767d auto merge of #7693 : korenchkin/rust/fixdoc_rand, r=cmr
All of the examples were still using `core::` instead of `std::` and  needed a `use std::rand;` at the top to compile
Most of the examples had
    `rng = rand::rng();`
instead of
    `let mut rng = rand::rng();`
2013-07-11 01:37:39 -07:00
Alex Crichton
f9bf69d253 Remove all external requirements of @ from TLS
Closes #6004
2013-07-11 00:37:13 -07:00
Alex Crichton
11c63eaad2 Fix a soundness problem with get 2013-07-11 00:22:08 -07:00
Alex Crichton
e3fb7062aa Work around stage0 to remove '@' requirements from TLS 2013-07-11 00:21:26 -07:00
bors
9239d69788 auto merge of #7691 : nikomatsakis/rust/vec-split-method, r=thestinger
I don't think we have this yet. This makes `&mut [T]` much more flexible.

r? @strcat (or whomever)
2013-07-10 23:37:40 -07:00
Daniel Micay
00da76dfbe vec: rm inline(never) hack
just avoid giving an inline hint in the first place
2013-07-11 02:17:08 -04:00
Daniel Micay
fd5f8d90c5 iterator: add DoubleEndedIterator concept
This implements the trait for vector iterators, replacing the reverse
iterator types. The methods will stay, for implementing the future
reverse Iterable traits and convenience.

This can also be trivially implemented for circular buffers and other
variants of arrays like strings and `SmallIntMap`/`SmallIntSet`.

The `DoubleEndedIterator` trait will allow for implementing algorithms
like in-place reverse on generic mutable iterators.

The naming (`Range` vs. `Iterator`, `Bidirectional` vs. `DoubleEnded`)
can be bikeshedded in the future.
2013-07-11 01:31:01 -04:00
Brendan Cully
e6e4f52bcf remove unused imports 2013-07-10 22:08:50 -07:00
bors
495741498c auto merge of #7690 : kevinmehall/rust/document-c_void, r=huonw
I added documentation for when to use and not to use `c_void`, since it tripped me up when I started. (See issue #7627)
2013-07-10 21:40:39 -07:00
bors
9b5d523126 auto merge of #7683 : alexcrichton/rust/issue-7625, r=thestinger
Closes #7625
2013-07-10 17:13:50 -07:00
Niko Matsakis
9ee5ce2215 Add a mut_split() method for dividing one &mut [T] into two 2013-07-10 10:03:29 -04:00
korenchkin
3cb3d754a5 Fixed examples
The examples were still using `core::` instead of `std::`
All of the examples needed a `use std::rand;` at the top to compile
Most of the examples had
    `rng = rand::rng();`
instead of
    `let mut rng = rand::rng();`
2013-07-10 15:49:39 +02:00
Kevin Mehall
663a9597b2 Document std::libc::c_void. 2013-07-10 08:55:14 -04:00
=Mark Sinclair
294999c350 Added overloaded Add and Sub traits for pointer arithmetic
Implemented ptr arithmetic for *T and *mut T. Tests passing
2013-07-10 06:34:00 -04:00
Daniel Micay
b5e9194836 Merge pull request #7682 from thestinger/vec
vec::with_capacity: do one alloc for non-managed + ptr module improvements
2013-07-10 01:06:34 -07:00
Alex Crichton
6d4d2c9a33 Don't loop infinitely on 0-size structs in repr
Closes #7625
2013-07-10 00:07:03 -07:00
Daniel Micay
6f5be9063d ptr: optimize {swap,replace,read}_ptr 2013-07-09 22:44:11 -04:00
Daniel Micay
f74250e3a9 vec::with_capacity: do one alloc for non-managed 2013-07-09 22:05:42 -04:00
bors
41dcec2fe1 auto merge of #7265 : brson/rust/io-upstream, r=brson
r? @graydon, @nikomatsakis, @pcwalton, or @catamorphism

Sorry this is so huge, but it's been accumulating for about a month. There's lots of stuff here, mostly oriented toward enabling multithreaded scheduling and improving compatibility between the old and new runtimes. Adds task pinning so that we can create the 'platform thread' in servo.

[Here](e1555f9b56/src/libstd/rt/mod.rs (L201)) is the current runtime setup code.

About half of this has already been reviewed.
2013-07-09 18:28:46 -07:00
Alex Crichton
cb5b9a477c Rename local_data methods/types for less keystrokes 2013-07-09 17:39:49 -07:00
Alex Crichton
5c3a2e7eeb Change TLS to almost be able to contain owned types 2013-07-09 17:31:01 -07:00
Alex Crichton
692a22e69d Change the elements in the task-local map to be actual key-value pairs 2013-07-09 17:31:01 -07:00
Alex Crichton
a89af1fa4c Use purely an owned vector for storing TLS data 2013-07-09 17:31:01 -07:00
Brian Anderson
413d51e32d std::rt: Ignore 0-byte udp reads 2013-07-09 16:54:56 -07:00
Brian Anderson
6fb92f8cab std::rt: Do local tests in a bare thread to not interfere with the scheduler 2013-07-09 15:48:22 -07:00