Skip to content

Commit 8060bd8

Browse files
cpetersocatamorphism
authored andcommitted
std: Mark some functions as pure
1 parent c1e58aa commit 8060bd8

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/libstd/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn Arena() -> Arena {
9595
}
9696

9797
#[inline(always)]
98-
fn round_up_to(base: uint, align: uint) -> uint {
98+
pure fn round_up_to(base: uint, align: uint) -> uint {
9999
(base + (align - 1)) & !(align - 1)
100100
}
101101

src/libstd/c_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
135135
*/
136136

137137
/// Returns the length of the vector
138-
pub fn len<T>(t: CVec<T>) -> uint {
138+
pub pure fn len<T>(t: CVec<T>) -> uint {
139139
return (*t).len;
140140
}
141141

src/libstd/list.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub enum List<T> {
2222
Nil,
2323
}
2424

25-
/// Cregate a list from a vector
26-
pub fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
25+
/// Create a list from a vector
26+
pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
2727
vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
2828
}
2929

@@ -53,7 +53,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T {
5353
* When function `f` returns true then an option containing the element
5454
* is returned. If `f` matches no elements then none is returned.
5555
*/
56-
pub fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> {
56+
pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> {
5757
let mut ls = ls;
5858
loop {
5959
ls = match *ls {
@@ -88,7 +88,7 @@ pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
8888
}
8989

9090
/// Returns the length of a list
91-
pub fn len<T>(ls: @List<T>) -> uint {
91+
pub pure fn len<T>(ls: @List<T>) -> uint {
9292
let mut count = 0u;
9393
iter(ls, |_e| count += 1u);
9494
count
@@ -131,7 +131,7 @@ pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
131131
*/
132132

133133
/// Iterate over a list
134-
pub fn iter<T>(l: @List<T>, f: fn(&T)) {
134+
pub pure fn iter<T>(l: @List<T>, f: fn(&T)) {
135135
let mut cur = l;
136136
loop {
137137
cur = match *cur {
@@ -145,7 +145,7 @@ pub fn iter<T>(l: @List<T>, f: fn(&T)) {
145145
}
146146

147147
/// Iterate over a list
148-
pub fn each<T>(l: @List<T>, f: fn(&T) -> bool) {
148+
pub pure fn each<T>(l: @List<T>, f: fn(&T) -> bool) {
149149
let mut cur = l;
150150
loop {
151151
cur = match *cur {

src/libstd/rope.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub type Rope = node::Root;
4343
*/
4444

4545
/// Create an empty rope
46-
pub fn empty() -> Rope {
46+
pub pure fn empty() -> Rope {
4747
return node::Empty;
4848
}
4949

@@ -479,7 +479,7 @@ pub mod iterator {
479479
*
480480
* Constant time.
481481
*/
482-
pub fn height(rope: Rope) -> uint {
482+
pub pure fn height(rope: Rope) -> uint {
483483
match (rope) {
484484
node::Empty => return 0u,
485485
node::Content(x) => return node::height(x)
@@ -1019,7 +1019,7 @@ mod node {
10191019
})
10201020
}
10211021

1022-
pub fn height(node: @Node) -> uint {
1022+
pub pure fn height(node: @Node) -> uint {
10231023
match (*node) {
10241024
Leaf(_) => return 0u,
10251025
Concat(ref x) => return x.height
@@ -1100,7 +1100,7 @@ mod node {
11001100
* proportional to the height of the rope + the (bounded)
11011101
* length of the largest leaf.
11021102
*/
1103-
pub fn char_at(node: @Node, pos: uint) -> char {
1103+
pub pure fn char_at(node: @Node, pos: uint) -> char {
11041104
let mut node = node;
11051105
let mut pos = pos;
11061106
loop {

0 commit comments

Comments
 (0)