From 2577e3eafca4bf8ba85c74240cc0ac832e5ae7d4 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 4 Apr 2012 18:01:55 -0700 Subject: [PATCH] Tidy up predicate names in libcore. Should close #1431. --- src/libcore/i16.rs | 10 +++++----- src/libcore/i32.rs | 10 +++++----- src/libcore/i64.rs | 10 +++++----- src/libcore/i8.rs | 10 +++++----- src/libcore/int.rs | 10 +++++----- src/libcore/result.rs | 10 +++++----- src/libcore/u16.rs | 8 ++++---- src/test/run-pass/cleanup-copy-mode.rs | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/libcore/i16.rs b/src/libcore/i16.rs index 30116f92b0e..6ae13ae4442 100644 --- a/src/libcore/i16.rs +++ b/src/libcore/i16.rs @@ -19,10 +19,10 @@ pure fn ne(x: i16, y: i16) -> bool { x != y } pure fn ge(x: i16, y: i16) -> bool { x >= y } pure fn gt(x: i16, y: i16) -> bool { x > y } -pure fn positive(x: i16) -> bool { x > 0i16 } -pure fn negative(x: i16) -> bool { x < 0i16 } -pure fn nonpositive(x: i16) -> bool { x <= 0i16 } -pure fn nonnegative(x: i16) -> bool { x >= 0i16 } +pure fn is_positive(x: i16) -> bool { x > 0i16 } +pure fn is_negative(x: i16) -> bool { x < 0i16 } +pure fn is_nonpositive(x: i16) -> bool { x <= 0i16 } +pure fn is_nonnegative(x: i16) -> bool { x >= 0i16 } #[doc = "Iterate over the range [`lo`..`hi`)"] fn range(lo: i16, hi: i16, it: fn(i16)) { @@ -37,5 +37,5 @@ pure fn compl(i: i16) -> i16 { #[doc = "Computes the absolute value"] pure fn abs(i: i16) -> i16 { - if negative(i) { -i } else { i } + if is_negative(i) { -i } else { i } } diff --git a/src/libcore/i32.rs b/src/libcore/i32.rs index faa2c71821a..9a6e4ff8a19 100644 --- a/src/libcore/i32.rs +++ b/src/libcore/i32.rs @@ -19,10 +19,10 @@ pure fn ne(x: i32, y: i32) -> bool { x != y } pure fn ge(x: i32, y: i32) -> bool { x >= y } pure fn gt(x: i32, y: i32) -> bool { x > y } -pure fn positive(x: i32) -> bool { x > 0i32 } -pure fn negative(x: i32) -> bool { x < 0i32 } -pure fn nonpositive(x: i32) -> bool { x <= 0i32 } -pure fn nonnegative(x: i32) -> bool { x >= 0i32 } +pure fn is_positive(x: i32) -> bool { x > 0i32 } +pure fn is_negative(x: i32) -> bool { x < 0i32 } +pure fn is_nonpositive(x: i32) -> bool { x <= 0i32 } +pure fn is_nonnegative(x: i32) -> bool { x >= 0i32 } #[doc = "Iterate over the range [`lo`..`hi`)"] fn range(lo: i32, hi: i32, it: fn(i32)) { @@ -37,5 +37,5 @@ pure fn compl(i: i32) -> i32 { #[doc = "Computes the absolute value"] pure fn abs(i: i32) -> i32 { - if negative(i) { -i } else { i } + if is_negative(i) { -i } else { i } } diff --git a/src/libcore/i64.rs b/src/libcore/i64.rs index a2e39a4b679..a0f8bf3e1eb 100644 --- a/src/libcore/i64.rs +++ b/src/libcore/i64.rs @@ -19,10 +19,10 @@ pure fn ne(x: i64, y: i64) -> bool { x != y } pure fn ge(x: i64, y: i64) -> bool { x >= y } pure fn gt(x: i64, y: i64) -> bool { x > y } -pure fn positive(x: i64) -> bool { x > 0i64 } -pure fn negative(x: i64) -> bool { x < 0i64 } -pure fn nonpositive(x: i64) -> bool { x <= 0i64 } -pure fn nonnegative(x: i64) -> bool { x >= 0i64 } +pure fn is_positive(x: i64) -> bool { x > 0i64 } +pure fn is_negative(x: i64) -> bool { x < 0i64 } +pure fn is_nonpositive(x: i64) -> bool { x <= 0i64 } +pure fn is_nonnegative(x: i64) -> bool { x >= 0i64 } #[doc = "Iterate over the range [`lo`..`hi`)"] fn range(lo: i64, hi: i64, it: fn(i64)) { @@ -37,5 +37,5 @@ pure fn compl(i: i64) -> i64 { #[doc = "Computes the absolute value"] pure fn abs(i: i64) -> i64 { - if negative(i) { -i } else { i } + if is_negative(i) { -i } else { i } } diff --git a/src/libcore/i8.rs b/src/libcore/i8.rs index 6f6e375d010..8d4e429ffc9 100644 --- a/src/libcore/i8.rs +++ b/src/libcore/i8.rs @@ -19,10 +19,10 @@ pure fn ne(x: i8, y: i8) -> bool { x != y } pure fn ge(x: i8, y: i8) -> bool { x >= y } pure fn gt(x: i8, y: i8) -> bool { x > y } -pure fn positive(x: i8) -> bool { x > 0i8 } -pure fn negative(x: i8) -> bool { x < 0i8 } -pure fn nonpositive(x: i8) -> bool { x <= 0i8 } -pure fn nonnegative(x: i8) -> bool { x >= 0i8 } +pure fn is_positive(x: i8) -> bool { x > 0i8 } +pure fn is_negative(x: i8) -> bool { x < 0i8 } +pure fn is_nonpositive(x: i8) -> bool { x <= 0i8 } +pure fn is_nonnegative(x: i8) -> bool { x >= 0i8 } #[doc = "Iterate over the range [`lo`..`hi`)"] fn range(lo: i8, hi: i8, it: fn(i8)) { @@ -37,5 +37,5 @@ pure fn compl(i: i8) -> i8 { #[doc = "Computes the absolute value"] pure fn abs(i: i8) -> i8 { - if negative(i) { -i } else { i } + if is_negative(i) { -i } else { i } } diff --git a/src/libcore/int.rs b/src/libcore/int.rs index 5aed338bd6b..bc482039019 100644 --- a/src/libcore/int.rs +++ b/src/libcore/int.rs @@ -30,10 +30,10 @@ pure fn ne(x: int, y: int) -> bool { ret x != y; } pure fn ge(x: int, y: int) -> bool { ret x >= y; } pure fn gt(x: int, y: int) -> bool { ret x > y; } -pure fn positive(x: int) -> bool { ret x > 0; } -pure fn negative(x: int) -> bool { ret x < 0; } -pure fn nonpositive(x: int) -> bool { ret x <= 0; } -pure fn nonnegative(x: int) -> bool { ret x >= 0; } +pure fn is_positive(x: int) -> bool { ret x > 0; } +pure fn is_negative(x: int) -> bool { ret x < 0; } +pure fn is_nonpositive(x: int) -> bool { ret x <= 0; } +pure fn is_nonnegative(x: int) -> bool { ret x >= 0; } #[doc = "Produce a uint suitable for use in a hash table"] pure fn hash(x: int) -> uint { ret x as uint; } @@ -112,7 +112,7 @@ pure fn compl(i: int) -> int { #[doc = "Computes the absolute value"] fn abs(i: int) -> int { - if negative(i) { -i } else { i } + if is_negative(i) { -i } else { i } } #[test] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 64385fca9bf..04dde5960db 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -44,7 +44,7 @@ pure fn get_err(res: result) -> U { } #[doc = "Returns true if the result is `ok`"] -pure fn success(res: result) -> bool { +pure fn is_success(res: result) -> bool { alt res { ok(_) { true } err(_) { false } @@ -52,8 +52,8 @@ pure fn success(res: result) -> bool { } #[doc = "Returns true if the result is `error`"] -pure fn failure(res: result) -> bool { - !success(res) +pure fn is_failure(res: result) -> bool { + !is_success(res) } #[doc = " @@ -113,9 +113,9 @@ impl extensions for result { fn get_err() -> E { get_err(self) } - fn success() -> bool { success(self) } + fn is_success() -> bool { is_success(self) } - fn failure() -> bool { failure(self) } + fn is_failure() -> bool { is_failure(self) } fn chain(op: fn(T) -> result) -> result { chain(self, op) diff --git a/src/libcore/u16.rs b/src/libcore/u16.rs index eb0965057e7..16ca4800f81 100644 --- a/src/libcore/u16.rs +++ b/src/libcore/u16.rs @@ -19,10 +19,10 @@ pure fn ne(x: u16, y: u16) -> bool { x != y } pure fn ge(x: u16, y: u16) -> bool { x >= y } pure fn gt(x: u16, y: u16) -> bool { x > y } -pure fn positive(x: u16) -> bool { x > 0u16 } -pure fn negative(x: u16) -> bool { x < 0u16 } -pure fn nonpositive(x: u16) -> bool { x <= 0u16 } -pure fn nonnegative(x: u16) -> bool { x >= 0u16 } +pure fn is_positive(x: u16) -> bool { x > 0u16 } +pure fn is_negative(x: u16) -> bool { x < 0u16 } +pure fn is_nonpositive(x: u16) -> bool { x <= 0u16 } +pure fn is_nonnegative(x: u16) -> bool { x >= 0u16 } #[doc = "Iterate over the range [`lo`..`hi`)"] fn range(lo: u16, hi: u16, it: fn(u16)) { diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index e66a4cd0ef5..0bcd7e65b72 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -2,7 +2,7 @@ fn adder(+x: @int, +y: @int) -> int { ret *x + *y; } fn failer() -> @int { fail; } fn main() { - assert(result::failure(task::try {|| + assert(result::is_failure(task::try {|| adder(@2, failer()); () })); }