Merge pull request #71 from plietar/master

Allow start and end of window to match length of underlying slice.
This commit is contained in:
Alex Crichton
2016-10-22 16:21:49 -07:00
committed by GitHub
+3 -3
View File
@@ -73,7 +73,7 @@ impl<T: AsRef<[u8]>> Window<T> {
/// This method will panic if `start` is out of bounds for the underlying
/// slice or if it comes after the `end` configured in this window.
pub fn set_start(&mut self, start: usize) -> &mut Window<T> {
assert!(start < self.inner.as_ref().len());
assert!(start <= self.inner.as_ref().len());
assert!(start <= self.range.end);
self.range.start = start;
self
@@ -86,9 +86,9 @@ impl<T: AsRef<[u8]>> Window<T> {
/// # Panics
///
/// This method will panic if `end` is out of bounds for the underlying
/// slice or if it comes after the `end` configured in this window.
/// slice or if it comes before the `start` configured in this window.
pub fn set_end(&mut self, end: usize) -> &mut Window<T> {
assert!(end < self.inner.as_ref().len());
assert!(end <= self.inner.as_ref().len());
assert!(self.range.start <= end);
self.range.end = end;
self