Skip to content

Commit e9b077c

Browse files
committed
auto merge of #5488 : pcwalton/rust/depure, r=pcwalton
2 parents b6f9aa1 + 3eda11a commit e9b077c

File tree

212 files changed

+2517
-2553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+2517
-2553
lines changed

src/libcore/at_vec.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub mod rustrt {
3838

3939
/// Returns the number of elements the vector can hold without reallocating
4040
#[inline(always)]
41-
pub pure fn capacity<T>(v: @[const T]) -> uint {
41+
pub fn capacity<T>(v: @[const T]) -> uint {
4242
unsafe {
4343
let repr: **raw::VecRepr =
4444
::cast::reinterpret_cast(&addr_of(&v));
@@ -59,8 +59,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint {
5959
* onto the vector being constructed.
6060
*/
6161
#[inline(always)]
62-
pub pure fn build_sized<A>(size: uint,
63-
builder: &fn(push: &pure fn(v: A))) -> @[A] {
62+
pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
6463
let mut vec: @[const A] = @[];
6564
unsafe { raw::reserve(&mut vec, size); }
6665
builder(|+x| unsafe { raw::push(&mut vec, x) });
@@ -78,7 +77,7 @@ pub pure fn build_sized<A>(size: uint,
7877
* onto the vector being constructed.
7978
*/
8079
#[inline(always)]
81-
pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
80+
pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
8281
build_sized(4, builder)
8382
}
8483

@@ -95,14 +94,15 @@ pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
9594
* onto the vector being constructed.
9695
*/
9796
#[inline(always)]
98-
pub pure fn build_sized_opt<A>(size: Option<uint>,
99-
builder: &fn(push: &pure fn(v: A))) -> @[A] {
97+
pub fn build_sized_opt<A>(size: Option<uint>,
98+
builder: &fn(push: &fn(v: A)))
99+
-> @[A] {
100100
build_sized(size.get_or_default(4), builder)
101101
}
102102

103103
// Appending
104104
#[inline(always)]
105-
pub pure fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
105+
pub fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
106106
do build_sized(lhs.len() + rhs.len()) |push| {
107107
for vec::each(lhs) |x| { push(*x); }
108108
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
@@ -111,7 +111,7 @@ pub pure fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
111111

112112

113113
/// Apply a function to each element of a vector and return the results
114-
pub pure fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
114+
pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
115115
do build_sized(v.len()) |push| {
116116
for vec::each(v) |elem| {
117117
push(f(elem));
@@ -125,7 +125,7 @@ pub pure fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
125125
* Creates an immutable vector of size `n_elts` and initializes the elements
126126
* to the value returned by the function `op`.
127127
*/
128-
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
128+
pub fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
129129
do build_sized(n_elts) |push| {
130130
let mut i: uint = 0u;
131131
while i < n_elts { push(op(i)); i += 1u; }
@@ -138,7 +138,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
138138
* Creates an immutable vector of size `n_elts` and initializes the elements
139139
* to the value `t`.
140140
*/
141-
pub pure fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
141+
pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
142142
do build_sized(n_elts) |push| {
143143
let mut i: uint = 0u;
144144
while i < n_elts { push(copy t); i += 1u; }
@@ -176,7 +176,7 @@ pub mod traits {
176176

177177
impl<T:Copy> Add<&'self [const T],@[T]> for @[T] {
178178
#[inline(always)]
179-
pure fn add(&self, rhs: & &'self [const T]) -> @[T] {
179+
fn add(&self, rhs: & &'self [const T]) -> @[T] {
180180
append(*self, (*rhs))
181181
}
182182
}

src/libcore/bool.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ use from_str::FromStr;
1717
#[cfg(notest)] use cmp;
1818

1919
/// Negation / inverse
20-
pub pure fn not(v: bool) -> bool { !v }
20+
pub fn not(v: bool) -> bool { !v }
2121

2222
/// Conjunction
23-
pub pure fn and(a: bool, b: bool) -> bool { a && b }
23+
pub fn and(a: bool, b: bool) -> bool { a && b }
2424

2525
/// Disjunction
26-
pub pure fn or(a: bool, b: bool) -> bool { a || b }
26+
pub fn or(a: bool, b: bool) -> bool { a || b }
2727

2828
/**
2929
* Exclusive or
3030
*
3131
* Identical to `or(and(a, not(b)), and(not(a), b))`
3232
*/
33-
pub pure fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
33+
pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
3434

3535
/// Implication in the logic, i.e. from `a` follows `b`
36-
pub pure fn implies(a: bool, b: bool) -> bool { !a || b }
36+
pub fn implies(a: bool, b: bool) -> bool { !a || b }
3737

3838
/// true if truth values `a` and `b` are indistinguishable in the logic
39-
pub pure fn eq(a: bool, b: bool) -> bool { a == b }
39+
pub fn eq(a: bool, b: bool) -> bool { a == b }
4040

4141
/// true if truth values `a` and `b` are distinguishable in the logic
42-
pub pure fn ne(a: bool, b: bool) -> bool { a != b }
42+
pub fn ne(a: bool, b: bool) -> bool { a != b }
4343

4444
/// true if `v` represents truth in the logic
45-
pub pure fn is_true(v: bool) -> bool { v }
45+
pub fn is_true(v: bool) -> bool { v }
4646

4747
/// true if `v` represents falsehood in the logic
48-
pub pure fn is_false(v: bool) -> bool { !v }
48+
pub fn is_false(v: bool) -> bool { !v }
4949

5050
/// Parse logic value from `s`
5151
impl FromStr for bool {
52-
static pure fn from_str(s: &str) -> Option<bool> {
52+
fn from_str(s: &str) -> Option<bool> {
5353
if s == "true" {
5454
Some(true)
5555
} else if s == "false" {
@@ -61,7 +61,7 @@ impl FromStr for bool {
6161
}
6262

6363
/// Convert `v` into a string
64-
pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
64+
pub fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
6565

6666
/**
6767
* Iterates over all truth values by passing them to `blk` in an unspecified
@@ -73,12 +73,12 @@ pub fn all_values(blk: &fn(v: bool)) {
7373
}
7474

7575
/// converts truth value to an 8 bit byte
76-
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
76+
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
7777

7878
#[cfg(notest)]
7979
impl cmp::Eq for bool {
80-
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
81-
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
80+
fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
81+
fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
8282
}
8383

8484
#[test]

src/libcore/cell.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ pub struct Cell<T> {
2121
}
2222

2323
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
24-
pure fn eq(&self, other: &Cell<T>) -> bool {
24+
fn eq(&self, other: &Cell<T>) -> bool {
2525
unsafe {
2626
let frozen_self: &Option<T> = transmute(&mut self.value);
2727
let frozen_other: &Option<T> = transmute(&mut other.value);
2828
frozen_self == frozen_other
2929
}
3030
}
31-
pure fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
31+
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
3232
}
3333

3434
/// Creates a new full cell with the given value.
3535
pub fn Cell<T>(value: T) -> Cell<T> {
3636
Cell { value: Some(value) }
3737
}
3838

39-
pub pure fn empty_cell<T>() -> Cell<T> {
39+
pub fn empty_cell<T>() -> Cell<T> {
4040
Cell { value: None }
4141
}
4242

@@ -61,7 +61,7 @@ pub impl<T> Cell<T> {
6161
}
6262

6363
/// Returns true if the cell is empty and false if the cell is full.
64-
pure fn is_empty(&self) -> bool {
64+
fn is_empty(&self) -> bool {
6565
self.value.is_none()
6666
}
6767

src/libcore/char.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use is_XID_continue = unicode::derived_property::XID_Continue;
6161
* in terms of the Unicode General Category 'Ll'
6262
*/
6363
#[inline(always)]
64-
pub pure fn is_lowercase(c: char) -> bool {
64+
pub fn is_lowercase(c: char) -> bool {
6565
return unicode::general_category::Ll(c);
6666
}
6767

@@ -70,7 +70,7 @@ pub pure fn is_lowercase(c: char) -> bool {
7070
* in terms of the Unicode General Category 'Lu'.
7171
*/
7272
#[inline(always)]
73-
pub pure fn is_uppercase(c: char) -> bool {
73+
pub fn is_uppercase(c: char) -> bool {
7474
return unicode::general_category::Lu(c);
7575
}
7676

@@ -80,7 +80,7 @@ pub pure fn is_uppercase(c: char) -> bool {
8080
* additional 'Cc'-category control codes in the range [0x09, 0x0d]
8181
*/
8282
#[inline(always)]
83-
pub pure fn is_whitespace(c: char) -> bool {
83+
pub fn is_whitespace(c: char) -> bool {
8484
return ('\x09' <= c && c <= '\x0d')
8585
|| unicode::general_category::Zs(c)
8686
|| unicode::general_category::Zl(c)
@@ -93,7 +93,7 @@ pub pure fn is_whitespace(c: char) -> bool {
9393
* and the Derived Core Property 'Alphabetic'.
9494
*/
9595
#[inline(always)]
96-
pub pure fn is_alphanumeric(c: char) -> bool {
96+
pub fn is_alphanumeric(c: char) -> bool {
9797
return unicode::derived_property::Alphabetic(c) ||
9898
unicode::general_category::Nd(c) ||
9999
unicode::general_category::Nl(c) ||
@@ -102,13 +102,13 @@ pub pure fn is_alphanumeric(c: char) -> bool {
102102

103103
/// Indicates whether the character is an ASCII character
104104
#[inline(always)]
105-
pub pure fn is_ascii(c: char) -> bool {
105+
pub fn is_ascii(c: char) -> bool {
106106
c - ('\x7F' & c) == '\x00'
107107
}
108108

109109
/// Indicates whether the character is numeric (Nd, Nl, or No)
110110
#[inline(always)]
111-
pub pure fn is_digit(c: char) -> bool {
111+
pub fn is_digit(c: char) -> bool {
112112
return unicode::general_category::Nd(c) ||
113113
unicode::general_category::Nl(c) ||
114114
unicode::general_category::No(c);
@@ -127,7 +127,7 @@ pub pure fn is_digit(c: char) -> bool {
127127
* Note: This just wraps `to_digit()`.
128128
*/
129129
#[inline(always)]
130-
pub pure fn is_digit_radix(c: char, radix: uint) -> bool {
130+
pub fn is_digit_radix(c: char, radix: uint) -> bool {
131131
match to_digit(c, radix) {
132132
Some(_) => true,
133133
None => false
@@ -148,7 +148,7 @@ pub pure fn is_digit_radix(c: char, radix: uint) -> bool {
148148
* Fails if given a `radix` outside the range `[0..36]`.
149149
*/
150150
#[inline]
151-
pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
151+
pub fn to_digit(c: char, radix: uint) -> Option<uint> {
152152
if radix > 36 {
153153
fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix));
154154
}
@@ -171,7 +171,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
171171
* Fails if given an `radix` > 36.
172172
*/
173173
#[inline]
174-
pub pure fn from_digit(num: uint, radix: uint) -> Option<char> {
174+
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
175175
if radix > 36 {
176176
fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num));
177177
}
@@ -195,7 +195,7 @@ pub pure fn from_digit(num: uint, radix: uint) -> Option<char> {
195195
* - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`
196196
* - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`
197197
*/
198-
pub pure fn escape_unicode(c: char) -> ~str {
198+
pub fn escape_unicode(c: char) -> ~str {
199199
let s = u32::to_str_radix(c as u32, 16u);
200200
let (c, pad) = (if c <= '\xff' { ('x', 2u) }
201201
else if c <= '\uffff' { ('u', 4u) }
@@ -223,7 +223,7 @@ pub pure fn escape_unicode(c: char) -> ~str {
223223
* - Any other chars in the range [0x20,0x7e] are not escaped.
224224
* - Any other chars are given hex unicode escapes; see `escape_unicode`.
225225
*/
226-
pub pure fn escape_default(c: char) -> ~str {
226+
pub fn escape_default(c: char) -> ~str {
227227
match c {
228228
'\t' => ~"\\t",
229229
'\r' => ~"\\r",
@@ -244,16 +244,16 @@ pub pure fn escape_default(c: char) -> ~str {
244244
* -1 if a < b, 0 if a == b, +1 if a > b
245245
*/
246246
#[inline(always)]
247-
pub pure fn cmp(a: char, b: char) -> int {
247+
pub fn cmp(a: char, b: char) -> int {
248248
return if b > a { -1 }
249249
else if b < a { 1 }
250250
else { 0 }
251251
}
252252

253253
#[cfg(notest)]
254254
impl Eq for char {
255-
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
256-
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
255+
fn eq(&self, other: &char) -> bool { (*self) == (*other) }
256+
fn ne(&self, other: &char) -> bool { (*self) != (*other) }
257257
}
258258

259259
#[test]

0 commit comments

Comments
 (0)