about summary refs log tree commit diff
path: root/src/libstd/str
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-08-15 05:23:33 +0200
committerblake2-ppc <blake2-ppc>2013-08-18 18:39:47 +0200
commit6066118b2988fee1b758d542cee18ffe7a84acab (patch)
treeaa5fadca63d12e8298653a9bc9f8186b7ac2778a /src/libstd/str
parent0a238288d343fc6323b37aad8678b3ea701fb7e3 (diff)
std::to_bytes: Delimit sequences &[A] and ~str when hashing
Address issue #5257, for example these values all had the same hash value:

	("aaa", "bbb", "ccc")
	("aaab", "bb", "ccc")
	("aaabbb", "", "ccc")

IterBytes for &[A] now includes the length, before calling iter_bytes on
each element.

IterBytes for &str is now terminated by a byte that does not appear in
UTF-8. This way only one more byte is processed when hashing strings.
Diffstat (limited to 'src/libstd/str')
-rw-r--r--src/libstd/str/ascii.rs2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs
index e0068f5e53e..1cfbf841537 100644
--- a/src/libstd/str/ascii.rs
+++ b/src/libstd/str/ascii.rs
@@ -376,7 +376,6 @@ static ASCII_UPPER_MAP: &'static [u8] = &[
 #[cfg(test)]
 mod tests {
     use super::*;
-    use to_bytes::ToBytes;
     use str::from_char;
 
     macro_rules! v2ascii (
@@ -445,7 +444,6 @@ mod tests {
 
     #[test]
     fn test_ascii_to_bytes() {
-        assert_eq!(v2ascii!(~[40, 32, 59]).to_bytes(false), ~[40u8, 32u8, 59u8]);
         assert_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), ~[40u8, 32u8, 59u8]);
     }