libcore: Implement Eq for string types
This commit is contained in:
parent
381a628c4c
commit
060609cd56
1 changed files with 25 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
* some heavy-duty uses, try std::rope.
|
* some heavy-duty uses, try std::rope.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import cmp::Eq;
|
||||||
import libc::size_t;
|
import libc::size_t;
|
||||||
import io::WriterUtil;
|
import io::WriterUtil;
|
||||||
|
|
||||||
|
@ -694,6 +695,30 @@ pure fn eq(a: &~str, b: &~str) -> bool {
|
||||||
/// Bytewise less than or equal
|
/// Bytewise less than or equal
|
||||||
pure fn le(a: &~str, b: &~str) -> bool { *a <= *b }
|
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
|
/// String hash function
|
||||||
pure fn hash(s: &~str) -> uint {
|
pure fn hash(s: &~str) -> uint {
|
||||||
hash::hash_str(*s) as uint
|
hash::hash_str(*s) as uint
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue