diff --git a/src/lib.rs b/src/lib.rs index cec30e3..f56b138 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,7 +334,7 @@ impl Cursive { /// Returns a mutable reference to the currently active screen. pub fn screen_mut(&mut self) -> &mut views::StackView { let id = self.active_screen; - self.screens.get_mut(id).unwrap() + &mut self.screens[id] } /// Adds a new screen, and returns its ID. @@ -515,7 +515,7 @@ impl Cursive { let printer = printer.sub_printer(Vec2::new(0, offset), printer.size, !selected); let id = self.active_screen; - self.screens.get_mut(id).unwrap().draw(&printer); + self.screens[id].draw(&printer); } diff --git a/src/utils/lines_iterator.rs b/src/utils/lines_iterator.rs index 77b651d..e85f994 100644 --- a/src/utils/lines_iterator.rs +++ b/src/utils/lines_iterator.rs @@ -95,7 +95,7 @@ impl<'a> Iterator for LinesIterator<'a> { // Find the ideal line, in an infinitely wide world. // We'll make a line larger than that. - let next = content.find('\n').unwrap_or(content.len()); + let next = content.find('\n').unwrap_or_else(|| content.len()); let content = &content[..next]; let allowed_width = if self.show_spaces { diff --git a/src/views/text_area.rs b/src/views/text_area.rs index a63be2c..eddd82a 100644 --- a/src/views/text_area.rs +++ b/src/views/text_area.rs @@ -315,7 +315,7 @@ impl TextArea { .find('\n') .map(|i| 1 + i + self.cursor); let last_row = last_byte.map_or(self.rows.len(), |last_byte| self.row_at(last_byte)); - let last_byte = last_byte.unwrap_or(self.content.len()); + let last_byte = last_byte.unwrap_or_else(|| self.content.len()); // println_stderr!("Content: `{}` (len={})", // self.content,