Commit Graph

17361 Commits

Author SHA1 Message Date
Tim Chevalier
58791c2fd8 Revert "libcore: remove unnecessary deref"
This reverts commit 9860fe10a1.
2013-04-29 14:30:52 -07:00
bors
dbcc3fe63a auto merge of #6110 : bjz/rust/numeric-traits, r=pcwalton
As discussed on issue #4819, I have created four new traits: `Algebraic`, `Trigonometric`, `Exponential` and `Hyperbolic`, and moved the appropriate methods into them from `Real`.

~~~rust
pub trait Algebraic {
    fn pow(&self, n: Self) -> Self;
    fn sqrt(&self) -> Self;
    fn rsqrt(&self) -> Self;
    fn cbrt(&self) -> Self;
    fn hypot(&self, other: Self) -> Self;
}

pub trait Trigonometric {
    fn sin(&self) -> Self;
    fn cos(&self) -> Self;
    fn tan(&self) -> Self;
    fn asin(&self) -> Self;
    fn acos(&self) -> Self;
    fn atan(&self) -> Self;
    fn atan2(&self, other: Self) -> Self;
}

pub trait Exponential {
    fn exp(&self) -> Self;
    fn exp2(&self) -> Self;
    fn expm1(&self) -> Self;
    fn log(&self) -> Self;
    fn log2(&self) -> Self;
    fn log10(&self) -> Self;
}

pub trait Hyperbolic: Exponential {
    fn sinh(&self) -> Self;
    fn cosh(&self) -> Self;
    fn tanh(&self) -> Self;
}
~~~

There was some discussion over whether we should shorten the names, for example `Trig` and `Exp`. No abbreviations have been agreed on yet, but this could be considered in the future.

Additionally, `Integer::divisible_by` has been renamed to `Integer::is_multiple_of`.
2013-04-29 13:39:37 -07:00
bors
76ec35ae74 auto merge of #6099 : danluu/rust/xfail_clone, r=catamorphism
One of the tests seems to have no current equivalent that's similar. Please let me know if that's incorrect, and I'll try fixing it instead of deleting it. I suppose a struct could be used instead of `any` and `match type`, but it seems like the original intent of the test was to exercise `match type`
2013-04-29 11:57:40 -07:00
Brendan Zabarauskas
500078e147 Revert "Merge Exponential and Hyperbolic traits"
After discussions on IRC and #4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
2013-04-29 23:50:34 +10:00
Brendan Zabarauskas
d3f494f5c3 Merge Exponential and Hyperbolic traits
The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's  simpler to group them the Exponential trait. In the future these would have default implementations.
2013-04-29 22:15:58 +10:00
ILYONG CHO
32901104cb tutorial: Fix 'self' to 'Self' 2013-04-29 18:03:11 +09:00
ILYONG CHO
9d33008da1 tutorial: Fix 'self' to 'Self' 2013-04-29 17:59:25 +09:00
bors
ea74f6845e auto merge of #6083 : jbclements/rust/parser-cleanup, r=jbclements
r? @pcwalton

A month's worth of parser cleanup here. Much of this is new comments and renaming. A number of these commits also remove unneeded code.  Probably the biggest refactor here is splitting "parse_item_or_view_item" into two functions; it turns out that the only overlap between items in foreign modules and items in regular modules was macros, so this refactor should make things substantially easier for future maintenance.
2013-04-29 00:12:37 -07:00
Brendan Zabarauskas
20ad931bf3 Rename 'divisible_by' method to 'is_multiple_of', add tests for 'is_odd' and 'is_even' 2013-04-29 16:03:48 +10:00
John Clements
cce13c18fe add test case for enum disambiguation 2013-04-28 23:01:41 -07:00
John Clements
cdf4d4bcdd fix typo in librstpkg tests, allowed by old parser 2013-04-28 23:01:41 -07:00
Brendan Zabarauskas
8f63f9789b Implement Fractional for Ratio 2013-04-29 16:00:27 +10:00
Brendan Zabarauskas
c9620dc052 Move appropriate functions out of Real and into separate Algebraic, Trigonometric, Exponential and Hyperbolic traits 2013-04-29 15:33:55 +10:00
bors
7b7a0fc235 auto merge of #6056 : thestinger/rust/iter, r=catamorphism
The existing adaptors like `map` in the `iter` module are very flawed because they only work for `BaseIter` implementations. There are many internal iterator implementations in the standard library like the set methods (`difference`, `symmetric_difference`, `intersection`, `union`) and the `range` functions that only share the `for` loop protocol in common.

The internal iterator adaptors should be implemented to work on any implementation of that protocol, rather than just a method called `each` taking `&self`.

This just moves `iter.rs` to `old_iter.rs` and begins work on documenting and implementing a nicer module.
2013-04-28 19:36:36 -07:00
Daniel Micay
46f91a0fa9 make way for a new iter module 2013-04-28 22:31:39 -04:00
bors
9f03d45c56 auto merge of #5646 : Aatch/rust/unwind-fix, r=brson
This fixes issue #5641
2013-04-28 15:36:35 -07:00
bors
1f9823375b auto merge of #6092 : gifnksm/rust/impl-integer-bigint, r=graydon
This is a follow-up commit for #6041 (and depending on #6048).
Also adding `#[inline(always)]` for almost every methods in `std::bigint`.
2013-04-28 12:51:35 -07:00
Dan Luu
e9814da3c0 Updated spawn / loop thread to work with current syntax 2013-04-28 15:33:41 -04:00
Dan Luu
212d77efcc Remove test for any type -> match type, which doesn't seem to exist anymore 2013-04-28 15:02:15 -04:00
Dan Luu
9968ccfc30 Update old xfailing spawn/bind/join test 2013-04-28 14:50:04 -04:00
John Clements
41af279233 parser comments 2013-04-28 09:51:16 -07:00
John Clements
2985f74ff3 s/one_tuple/trailing_comma (more accurate name) 2013-04-28 09:51:16 -07:00
John Clements
aa346401ba removed unneeded argument to parse_record 2013-04-28 09:51:16 -07:00
John Clements
d2aee7b3e6 s/parse_purity/parse_unsafety 2013-04-28 09:51:16 -07:00
John Clements
1abc1be81a remove 3-line used-once function 2013-04-28 09:51:16 -07:00
John Clements
7ef92ba246 rename parse_instance_var to parse_name_and_ty
the name no longer made sense. perhaps this could just be inlined.
2013-04-28 09:51:15 -07:00
John Clements
2a74c58588 remove obsolete semicolon from list of suggestions 2013-04-28 09:51:15 -07:00
John Clements
915e76a974 rename parse_single_class_item as well 2013-04-28 09:51:15 -07:00
John Clements
968089e422 rename parse_class_item to parse_struct_decl_field
two problems with the old name: they're not called classes any more, and
the word "item" has a specific connotation in the parser
2013-04-28 09:51:15 -07:00
John Clements
b82724db22 needs_comma was always true 2013-04-28 09:51:15 -07:00
John Clements
703390150a fix for parsing x() as identifier pattern 2013-04-28 09:51:15 -07:00
John Clements
5119597dc6 hard to read the implied double negative 2013-04-28 09:51:15 -07:00
John Clements
3c10a9412e remove unused functions, fix tiny lexing bug
before this change, the parser would parse 14.a() as a method call, but
would parse 14.ø() as the floating-point number 14. followed by a function
call. This is because it was checking is_alpha, rather than ident_start,
and was therefore wrong with respect to unicode.
2013-04-28 09:51:15 -07:00
John Clements
5411cbf656 remove unused flag to parse_local fn 2013-04-28 09:51:14 -07:00
John Clements
63397b8519 remove unused RESTRICT_NO_CALL_EXPRS restriction 2013-04-28 09:51:14 -07:00
John Clements
2733a1f14b undo abstraction over whether to parse attrs in a block
In principle, it seems like a nice idea to abstract over the two
functions that parse blocks (one with inner attrs allowed, one not).
However, the existing one wound up making things more complex than
just having two separate functions, especially after the obsolete
syntax is (will be) removed.
2013-04-28 09:51:14 -07:00
John Clements
ab03c1e422 refactoring to split foreign_items from items 2013-04-28 09:51:14 -07:00
John Clements
fa5ba17c89 parser comments
parser comments
2013-04-28 09:51:14 -07:00
John Clements
1b4ced8bcb get rid of prec.rs
prec.rs no longer had much to do with precedence; the token->binop
function fits better in token.rs, and the one-liner defining the
precedence of 'as' can go next to the other precedence stuff in
ast_util.rs
2013-04-28 09:51:14 -07:00
John Clements
9f8d30a128 reindent in parser 2013-04-28 09:49:21 -07:00
John Clements
a818648aa9 remove unnecessary function 2013-04-28 09:49:20 -07:00
John Clements
71c0bd5c5d simplify, based on invariant that items_allowed != foreign_items_allowed 2013-04-28 09:49:20 -07:00
John Clements
ae4e09f71a adding parse_path 2013-04-28 09:49:20 -07:00
John Clements
28b285764c comments, helper function for tests, more informative error message 2013-04-28 09:49:20 -07:00
John Clements
50a7f5483b refactor parse_fn_decl 2013-04-28 09:49:20 -07:00
John Clements
2b7f1a4f24 parser comments only 2013-04-28 09:49:20 -07:00
John Clements
c73a9c9cd0 refactoring mod.rs 2013-04-28 09:49:20 -07:00
John Clements
a2493ad048 change stage1,stage2,stage2 into not(stage0)
With luck, this will allow rust to compile itself without --cfg flags again...
2013-04-28 09:49:20 -07:00
bors
cdd342bd34 auto merge of #6097 : Blei/rust/fix-rand, r=pnkfelix
`self` has type `&@Rand`, so `*self` will be of type `@Rand` which causes
this same impl to be called again.

Fixes #6061
2013-04-28 04:48:35 -07:00
Philipp Brüschweiler
8627fc9726 rand: Fix infinite recursion
`self` has type `&@Rand`, so `*self` will be of type `@Rand` which causes
this same impl to be called again.
2013-04-28 13:31:49 +02:00