aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/str.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-05-01 21:19:11 +0200
committerMs2ger <ms2ger@gmail.com>2015-05-01 21:19:11 +0200
commit84b1b5268217d2be6fc729282cd4a921c93ccc5b (patch)
tree645d39ff104513a3f59dc5a6b4f6d5eb4fb75ea7 /components/script/dom/bindings/str.rs
parent0a5ffc4bb04304c4bdd1e6cebcadb7823e1bff1f (diff)
downloadservo-84b1b5268217d2be6fc729282cd4a921c93ccc5b.tar.gz
servo-84b1b5268217d2be6fc729282cd4a921c93ccc5b.zip
Replace ByteString::as_slice() by a Deref implementation.
Diffstat (limited to 'components/script/dom/bindings/str.rs')
-rw-r--r--components/script/dom/bindings/str.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs
index fff381e98f8..4b275baa934 100644
--- a/components/script/dom/bindings/str.rs
+++ b/components/script/dom/bindings/str.rs
@@ -6,6 +6,7 @@
use std::borrow::ToOwned;
use std::hash::{Hash, Hasher};
+use std::ops;
use std::str;
use std::str::FromStr;
@@ -27,12 +28,6 @@ impl ByteString {
str::from_utf8(&vec).ok()
}
- /// Returns the underlying vector as a slice.
- pub fn as_slice<'a>(&'a self) -> &'a [u8] {
- let ByteString(ref vector) = *self;
- vector
- }
-
/// Returns the length.
pub fn len(&self) -> usize {
let ByteString(ref vector) = *self;
@@ -158,6 +153,13 @@ impl FromStr for ByteString {
}
}
+impl ops::Deref for ByteString {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ &self.0
+ }
+}
+
/// A string that is constructed from a UCS-2 buffer by replacing invalid code
/// points with the replacement character.
pub struct USVString(pub String);