about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorChris Peterson <cpeterson@mozilla.com>2012-12-23 14:38:01 -0800
committerChris Peterson <cpeterson@mozilla.com>2012-12-23 14:38:01 -0800
commitffaa47736866ca89b8d23cd3f14d54efefdb6243 (patch)
treeb50b45c4598ce48f3dc62610d299ee76ba74ce88 /src/libstd
parent6d8621ae7f0df0bc3878c256b98a6483fc3d9a32 (diff)
downloadrust-ffaa47736866ca89b8d23cd3f14d54efefdb6243.tar.gz
rust-ffaa47736866ca89b8d23cd3f14d54efefdb6243.zip
std: Mark some functions as pure
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/arena.rs2
-rw-r--r--src/libstd/c_vec.rs2
-rw-r--r--src/libstd/list.rs12
-rw-r--r--src/libstd/rope.rs8
4 files changed, 12 insertions, 12 deletions
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs
index 105e8fb122f..9054f9355ad 100644
--- a/src/libstd/arena.rs
+++ b/src/libstd/arena.rs
@@ -95,7 +95,7 @@ pub fn Arena() -> Arena {
 }
 
 #[inline(always)]
-fn round_up_to(base: uint, align: uint) -> uint {
+pure fn round_up_to(base: uint, align: uint) -> uint {
     (base + (align - 1)) & !(align - 1)
 }
 
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs
index cd1fa33a08f..cc8cadb709d 100644
--- a/src/libstd/c_vec.rs
+++ b/src/libstd/c_vec.rs
@@ -135,7 +135,7 @@ pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
  */
 
 /// Returns the length of the vector
-pub fn len<T>(t: CVec<T>) -> uint {
+pub pure fn len<T>(t: CVec<T>) -> uint {
     return (*t).len;
 }
 
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index 6d2c10eb827..e41aab8ec1f 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -22,8 +22,8 @@ pub enum List<T> {
     Nil,
 }
 
-/// Cregate a list from a vector
-pub fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
+/// Create a list from a vector
+pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
     vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
 }
 
@@ -53,7 +53,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T {
  * When function `f` returns true then an option containing the element
  * is returned. If `f` matches no elements then none is returned.
  */
-pub fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> {
+pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> {
     let mut ls = ls;
     loop {
         ls = match *ls {
@@ -88,7 +88,7 @@ pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
 }
 
 /// Returns the length of a list
-pub fn len<T>(ls: @List<T>) -> uint {
+pub pure fn len<T>(ls: @List<T>) -> uint {
     let mut count = 0u;
     iter(ls, |_e| count += 1u);
     count
@@ -131,7 +131,7 @@ pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
 */
 
 /// Iterate over a list
-pub fn iter<T>(l: @List<T>, f: fn(&T)) {
+pub pure fn iter<T>(l: @List<T>, f: fn(&T)) {
     let mut cur = l;
     loop {
         cur = match *cur {
@@ -145,7 +145,7 @@ pub fn iter<T>(l: @List<T>, f: fn(&T)) {
 }
 
 /// Iterate over a list
-pub fn each<T>(l: @List<T>, f: fn(&T) -> bool) {
+pub pure fn each<T>(l: @List<T>, f: fn(&T) -> bool) {
     let mut cur = l;
     loop {
         cur = match *cur {
diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs
index 473992e6820..aa78d22e4c8 100644
--- a/src/libstd/rope.rs
+++ b/src/libstd/rope.rs
@@ -43,7 +43,7 @@ pub type Rope = node::Root;
  */
 
 /// Create an empty rope
-pub fn empty() -> Rope {
+pub pure fn empty() -> Rope {
    return node::Empty;
 }
 
@@ -479,7 +479,7 @@ pub mod iterator {
  *
  * Constant time.
  */
-pub fn height(rope: Rope) -> uint {
+pub pure fn height(rope: Rope) -> uint {
    match (rope) {
       node::Empty      => return 0u,
       node::Content(x) => return node::height(x)
@@ -1019,7 +1019,7 @@ mod node {
                     })
     }
 
-    pub fn height(node: @Node) -> uint {
+    pub pure fn height(node: @Node) -> uint {
         match (*node) {
           Leaf(_)   => return 0u,
           Concat(ref x) => return x.height
@@ -1100,7 +1100,7 @@ mod node {
      * proportional to the height of the rope + the (bounded)
      * length of the largest leaf.
      */
-    pub fn char_at(node: @Node, pos: uint) -> char {
+    pub pure fn char_at(node: @Node, pos: uint) -> char {
         let mut node    = node;
         let mut pos     = pos;
         loop {