about summary refs log tree commit diff
path: root/src/libstd/sys/sgx
diff options
context:
space:
mode:
authorThomas de Zeeuw <thomasdezeeuw@gmail.com>2019-07-25 22:30:52 +0200
committerThomas de Zeeuw <thomasdezeeuw@gmail.com>2019-08-03 10:44:45 +0200
commitdad56c39474377c7d47e261b380d0be3aed104cc (patch)
tree52b4ad99a6f344fe292a0b0b6b38c6089eee8ad6 /src/libstd/sys/sgx
parentd7270712cb446aad0817040bbca73a8d024f67b0 (diff)
downloadrust-dad56c39474377c7d47e261b380d0be3aed104cc.tar.gz
rust-dad56c39474377c7d47e261b380d0be3aed104cc.zip
Add {IoSlice, IoSliceMut}::advance
Diffstat (limited to 'src/libstd/sys/sgx')
-rw-r--r--src/libstd/sys/sgx/io.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/sys/sgx/io.rs b/src/libstd/sys/sgx/io.rs
index 4b423a5cbc1..976e122463d 100644
--- a/src/libstd/sys/sgx/io.rs
+++ b/src/libstd/sys/sgx/io.rs
@@ -1,3 +1,5 @@
+use crate::mem;
+
 pub struct IoSlice<'a>(&'a [u8]);
 
 impl<'a> IoSlice<'a> {
@@ -7,6 +9,11 @@ impl<'a> IoSlice<'a> {
     }
 
     #[inline]
+    pub fn advance(&mut self, n: usize) {
+        self.0 = &self.0[n..]
+    }
+
+    #[inline]
     pub fn as_slice(&self) -> &[u8] {
         self.0
     }
@@ -21,6 +28,13 @@ impl<'a> IoSliceMut<'a> {
     }
 
     #[inline]
+    pub fn advance(&mut self, n: usize) {
+        let slice = mem::replace(&mut self.0, &mut []);
+        let (_, remaining) = slice.split_at_mut(n);
+        self.0 = remaining;
+    }
+
+    #[inline]
     pub fn as_slice(&self) -> &[u8] {
         self.0
     }