Skip to content

Commit c5f2c1d

Browse files
committed
add some purity annotations in core
1 parent c5d168c commit c5f2c1d

File tree

3 files changed

+72
-75
lines changed

3 files changed

+72
-75
lines changed

src/libcore/option.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ pure fn get<T: copy>(opt: option<T>) -> T {
2525
alt opt { some(x) { ret x; } none { fail "option none"; } }
2626
}
2727

28-
fn map<T, U: copy>(opt: option<T>, f: fn(T) -> U) -> option<U> {
28+
pure fn map<T, U: copy>(opt: option<T>, f: fn(T) -> U) -> option<U> {
2929
#[doc = "Maps a `some` value from one type to another"];
3030

3131
alt opt { some(x) { some(f(x)) } none { none } }
3232
}
3333

34-
fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> {
34+
pure fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> {
3535
#[doc = "
3636
Update an optional value by optionally running its content through a
3737
function that returns an option.
@@ -58,19 +58,19 @@ pure fn get_default<T: copy>(opt: option<T>, def: T) -> T {
5858
alt opt { some(x) { x } none { def } }
5959
}
6060

61-
fn map_default<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
61+
pure fn map_default<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
6262
#[doc = "Applies a function to the contained value or returns a default"];
6363

6464
alt opt { none { def } some(t) { f(t) } }
6565
}
6666

67-
fn iter<T>(opt: option<T>, f: fn(T)) {
67+
pure fn iter<T>(opt: option<T>, f: fn(T)) {
6868
#[doc = "Performs an operation on the contained value or does nothing"];
6969

7070
alt opt { none { } some(t) { f(t); } }
7171
}
7272

73-
fn unwrap<T>(-opt: option<T>) -> T unsafe {
73+
pure fn unwrap<T>(-opt: option<T>) -> T unsafe {
7474
#[doc = "
7575
Moves a value out of an option type and returns it.
7676

src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ fn reserve_at_least(&s: str, n: uint) unsafe {
16191619
Returns the number of single-byte characters the string can hold without
16201620
reallocating
16211621
"]
1622-
fn capacity(&&s: str) -> uint unsafe {
1622+
pure fn capacity(&&s: str) -> uint unsafe {
16231623
as_bytes(s) {|buf|
16241624
let vcap = vec::capacity(buf);
16251625
assert vcap > 0u;

0 commit comments

Comments
 (0)