aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-21 16:43:28 -0800
committerGraydon Hoare <[email protected]>2010-12-21 16:43:28 -0800
commit3504f4a4bf492886aa6cc7b2eae5d8e0100e9d51 (patch)
treeab9592156d3e9de9ce6811cbf508a7e94f1fe4d5 /src/lib
parentrustc: Move type logic out of typeck so trans doesn't look like it's calling ... (diff)
downloadrust-3504f4a4bf492886aa6cc7b2eae5d8e0100e9d51.tar.xz
rust-3504f4a4bf492886aa6cc7b2eae5d8e0100e9d51.zip
Sort methods in object types.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/_str.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index 4ea5ca28..55fe1142 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -27,6 +27,31 @@ fn eq(&str a, &str b) -> bool {
ret true;
}
+fn lteq(&str a, &str b) -> bool {
+ let uint i = byte_len(a);
+ let uint j = byte_len(b);
+ let uint n = i;
+ if (j < n) {
+ n = j;
+ }
+
+ let uint x = 0u;
+ while (x < n) {
+ auto cha = a.(x);
+ auto chb = b.(x);
+ if (cha <= chb) {
+ ret true;
+ }
+ else if (cha > chb) {
+ ret false;
+ }
+ x += 1u;
+ }
+
+ ret i <= j;
+}
+
+
fn hash(&str s) -> uint {
// djb hash.
// FIXME: replace with murmur.