diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-27 16:57:20 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-27 16:57:20 -0700 |
| commit | 060609cd568454ecbe8565ab699718f13ff71a26 (patch) | |
| tree | e5478ef0a0ba40edb759435856d8787f13c76da6 | |
| parent | 381a628c4c49d2cbfabe8a60216809d45e316704 (diff) | |
libcore: Implement Eq for string types
| -rw-r--r-- | src/libcore/str.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index d2e9ad6019b..2ca21383dd5 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -7,6 +7,7 @@ * some heavy-duty uses, try std::rope. */ +import cmp::Eq; import libc::size_t; import io::WriterUtil; @@ -694,6 +695,30 @@ pure fn eq(a: &~str, b: &~str) -> bool { /// Bytewise less than or equal pure fn le(a: &~str, b: &~str) -> bool { *a <= *b } +#[cfg(notest)] +impl &str: Eq { + #[inline(always)] + pure fn eq(&&other: &str) -> bool { + eq_slice(self, other) + } +} + +#[cfg(notest)] +impl ~str: Eq { + #[inline(always)] + pure fn eq(&&other: ~str) -> bool { + eq_slice(self, other) + } +} + +#[cfg(notest)] +impl @str: Eq { + #[inline(always)] + pure fn eq(&&other: @str) -> bool { + eq_slice(self, other) + } +} + /// String hash function pure fn hash(s: &~str) -> uint { hash::hash_str(*s) as uint |
