diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2018-09-18 01:34:56 +0200 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-09-17 23:34:56 +0000 |
commit | 63a40df5203178bbea1ff1a6988e6d30b6f992f4 (patch) | |
tree | cdfef3dbeaf3fc53844574c58082c08cf4e7a202 | |
parent | 55e675a3d89922d9d7966cd7bccf0da9d9eff654 (diff) |
Fix style issues
-rw-r--r-- | font/src/darwin/mod.rs | 2 | ||||
-rw-r--r-- | font/src/ft/fc/font_set.rs | 2 | ||||
-rw-r--r-- | src/grid/row.rs | 19 | ||||
-rw-r--r-- | src/grid/storage.rs | 4 | ||||
-rw-r--r-- | src/locale.rs | 2 | ||||
-rw-r--r-- | src/term/mod.rs | 2 |
6 files changed, 24 insertions, 7 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs index 2f9d5fe0..bbdb5662 100644 --- a/font/src/darwin/mod.rs +++ b/font/src/darwin/mod.rs @@ -68,7 +68,7 @@ impl Descriptor { font_name: desc.font_name(), style_name: desc.style_name(), display_name: desc.display_name(), - font_path: desc.font_path().unwrap_or_else(||{"".to_owned()}), + font_path: desc.font_path().unwrap_or_else(String::new), ct_descriptor: desc, } } diff --git a/font/src/ft/fc/font_set.rs b/font/src/ft/fc/font_set.rs index a0c4eee0..6b63f439 100644 --- a/font/src/ft/fc/font_set.rs +++ b/font/src/ft/fc/font_set.rs @@ -99,7 +99,7 @@ impl<'a> Iterator for Iter<'a> { None } else { let pattern = unsafe { - let ptr = *(*self.font_set.as_ptr()).fonts.offset(self.current as isize); + let ptr = *(*self.font_set.as_ptr()).fonts.add(self.current); PatternRef::from_ptr(ptr) }; diff --git a/src/grid/row.rs b/src/grid/row.rs index 69a4f2b2..7c12bf99 100644 --- a/src/grid/row.rs +++ b/src/grid/row.rs @@ -15,7 +15,7 @@ //! Defines the Row type which makes up lines in the grid use std::ops::{Index, IndexMut}; -use std::ops::{Range, RangeTo, RangeFrom, RangeFull}; +use std::ops::{Range, RangeTo, RangeFrom, RangeFull, RangeToInclusive}; use std::cmp::{max, min}; use std::slice; @@ -200,3 +200,20 @@ impl<T> IndexMut<RangeFull> for Row<T> { &mut self.inner[..] } } + +impl<T> Index<RangeToInclusive<Column>> for Row<T> { + type Output = [T]; + + #[inline] + fn index(&self, index: RangeToInclusive<Column>) -> &[T] { + &self.inner[..=(index.end.0)] + } +} + +impl<T> IndexMut<RangeToInclusive<Column>> for Row<T> { + #[inline] + fn index_mut(&mut self, index: RangeToInclusive<Column>) -> &mut [T] { + self.occ = max(self.occ, *index.end); + &mut self.inner[..=(index.end.0)] + } +} diff --git a/src/grid/storage.rs b/src/grid/storage.rs index ad94cf2b..af2bd35c 100644 --- a/src/grid/storage.rs +++ b/src/grid/storage.rs @@ -232,8 +232,8 @@ impl<T> Storage<T> { // Cast to a qword array to opt out of copy restrictions and avoid // drop hazards. Byte array is no good here since for whatever // reason LLVM won't optimized it. - let a_ptr = self.inner.as_mut_ptr().offset(a as isize) as *mut u64; - let b_ptr = self.inner.as_mut_ptr().offset(b as isize) as *mut u64; + let a_ptr = self.inner.as_mut_ptr().add(a) as *mut u64; + let b_ptr = self.inner.as_mut_ptr().add(b) as *mut u64; // Copy 1 qword at a time // diff --git a/src/locale.rs b/src/locale.rs index bea68cad..833de71e 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -67,7 +67,7 @@ pub fn set_locale_environment() { // try setting `locale_id` let modified = setlocale(LC_CTYPE, locale_ptr); let result = if modified.is_null() { - String::from("") + String::new() } else { locale_id }; diff --git a/src/term/mod.rs b/src/term/mod.rs index 04d110af..f4ebf1c9 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1725,7 +1725,7 @@ impl ansi::Handler for Term { }, ansi::LineClearMode::Left => { let row = &mut self.grid[self.cursor.point.line]; - for cell in &mut row[..(col + 1)] { + for cell in &mut row[..=col] { cell.reset(&template); } }, |