diff options
Diffstat (limited to 'compiler/rustc_serialize/src')
| -rw-r--r-- | compiler/rustc_serialize/src/opaque.rs | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 1b4b1d2436f..1dcb69920d7 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -17,7 +17,7 @@ use crate::int_overflow::DebugStrictAdd; pub type FileEncodeResult = Result<usize, (PathBuf, io::Error)>; -const FOOTER: &[u8] = b"rust-end-file"; +pub const MAGIC_END_BYTES: &[u8] = b"rust-end-file"; /// The size of the buffer in `FileEncoder`. const BUF_SIZE: usize = 8192; @@ -183,7 +183,7 @@ impl FileEncoder { } pub fn finish(&mut self) -> FileEncodeResult { - self.write_all(FOOTER); + self.write_all(MAGIC_END_BYTES); self.flush(); #[cfg(debug_assertions)] { @@ -264,10 +264,10 @@ pub struct MemDecoder<'a> { impl<'a> MemDecoder<'a> { #[inline] - pub fn new(data: &'a [u8], position: usize) -> Option<MemDecoder<'a>> { - let data = data.strip_suffix(FOOTER)?; + pub fn new(data: &'a [u8], position: usize) -> Result<MemDecoder<'a>, ()> { + let data = data.strip_suffix(MAGIC_END_BYTES).ok_or(())?; let Range { start, end } = data.as_ptr_range(); - Some(MemDecoder { start, current: data[position..].as_ptr(), end, _marker: PhantomData }) + Ok(MemDecoder { start, current: data[position..].as_ptr(), end, _marker: PhantomData }) } #[inline] | 
