Skip to content

Commit

Permalink
Do not return &mut Self
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and cramertj committed Jun 13, 2019
1 parent ae72278 commit b232653
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions futures-util/src/io/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ impl<T: AsRef<[u8]>> Window<T> {

/// Changes the range of this window to the range specified.
///
/// Returns the windows back to chain multiple calls to this method.
///
/// # Panics
///
/// This method will panic if `range` is out of bounds for the underlying
/// slice or if [`start_bound()`] of `range` comes after the [`end_bound()`].
///
/// [`start_bound()`]: std::ops::RangeBounds::start_bound
/// [`end_bound()`]: std::ops::RangeBounds::end_bound
pub fn set<R: RangeBounds<usize>>(&mut self, range: R) -> &mut Self {
pub fn set<R: RangeBounds<usize>>(&mut self, range: R) {
let start = match range.start_bound() {
Bound::Included(n) => *n,
Bound::Excluded(n) => *n + 1,
Expand All @@ -93,7 +91,6 @@ impl<T: AsRef<[u8]>> Window<T> {

self.range.start = start;
self.range.end = end;
self
}
}

Expand Down
8 changes: 4 additions & 4 deletions futures/tests/io_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use futures::io::Window;
#[test]
fn set() {
let mut buffer = Window::new(&[1, 2, 3]);
buffer.set(..3)
.set(3..3)
.set(3..=2) // == 3..3
.set(0..2);
buffer.set(..3);
buffer.set(3..3);
buffer.set(3..=2); // == 3..3
buffer.set(0..2);

assert_eq!(buffer.as_ref(), &[1, 2]);
}
Expand Down

0 comments on commit b232653

Please sign in to comment.