summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxanonid <xanonid@gmail.com>2018-10-24 09:23:02 +0200
committerxanonid <xanonid@gmail.com>2018-10-24 09:23:02 +0200
commit43a3cdcee50dd13c49daf57badb85709d85287f6 (patch)
treec901ae89de02bc20db6c5d21fa57e613d396b37b
parent6f01431763041f7a321660cc2c6a89836f0c77ac (diff)
Improve code style (suggestion by clippy)
- usize never < 0 - convert transmute to casts - simplify condition
-rw-r--r--src/cell.rs2
-rw-r--r--src/lib.rs3
-rw-r--r--src/row.rs2
3 files changed, 3 insertions, 4 deletions
diff --git a/src/cell.rs b/src/cell.rs
index bc25cec..f27b1bd 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -190,7 +190,7 @@ impl Cell {
/// Set horizontal span for this cell (must be > 0)
pub fn set_hspan(&mut self, hspan: usize) {
- self.hspan = if hspan <= 0 {1} else {hspan};
+ self.hspan = if hspan == 0 {1} else {hspan};
}
/// Get horizontal span of this cell (> 0)
diff --git a/src/lib.rs b/src/lib.rs
index 65f8b0c..0674793 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,7 +15,6 @@ use std::fmt;
use std::iter::{FromIterator, IntoIterator};
use std::slice::{Iter, IterMut};
use std::ops::{Index, IndexMut};
-use std::mem::transmute;
pub use term::{Attr, color};
pub(crate) use term::{Terminal, stdout};
@@ -502,7 +501,7 @@ impl<'a> AsRef<TableSlice<'a>> for Table {
// All this is a bit hacky. Let's try to find something else
let s = &mut *((self as *const Table) as *mut Table);
s.rows.shrink_to_fit();
- transmute(self)
+ &*(self as *const Table as *const TableSlice<'a>)
}
}
}
diff --git a/src/row.rs b/src/row.rs
index 856a8e0..5f34a24 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -66,7 +66,7 @@ impl Row {
pub fn get_column_width(&self, column: usize, format: &TableFormat) -> usize {
let mut i = 0;
for c in &self.cells {
- if i + c.get_hspan()-1 >= column {
+ if i + c.get_hspan() > column {
if c.get_hspan() == 1 {
return c.get_width();
}